-
-
Notifications
You must be signed in to change notification settings - Fork 49.6k
Closed
Description
We had given a task and for which we written below code, while executing it showing an error. Please let us know where we went wrong in coding-
import os
import json
def func1(value):
a=json.loads(value)
b = json.dumps(a, indent=1)
return b
if __name__ == "__main__":
try:
data=input()
b=func1(data)
print(True)
print(b[1].values())
except ValueError as error:
print(False)
After executing it we are getting as -
Compiler Message
Runtime Error
Error (stderr)
Traceback (most recent call last):
File "Solution.py", line 14, in <module>
print(b[1].values())
AttributeError: 'str' object has no attribute 'values'
Input (stdin)
[{"1": "Student1", "Marks": 90}, {"2": "Student2", "Marks": 95}]
Your Output (stdout)
True
Expected Output
True
dict_values(['Student2', 95])
Metadata
Metadata
Assignees
Labels
No labels