Doubt regarding Assignment json

import json

emp = {
{

		"Name" : input("Enter the name of Employee1 : "),
		" dob " : input("Enter the DOB of Employee1 : "),
		"height" : input("Enter the Height of the Employee1 : "),
		"City "  : input("Enter the City of Employee1 : "),
		"State" : input("Enter the State of Employee1 : ")
	},    
	{

		"Name" : input("Enter the name of Employee2 : "),
		" dob " : input("Enter the DOB of Employee2 : "),
		"height" :input("Enter the Height of the Employee2 : "),
		"City "  : input("Enter the City of Employee2 : "),
		"State" : input("Enter the State of Employee2 : ")
	},    
	{

		"Name" : input("Enter the name of Employee3 : "),
		" dob " : input("Enter the DOB of Employee3 : "),
		"height" : input("Enter the Height of the Employee3 : "),
		"City "  : input("Enter the City of Employee3 : "),
		"State" : input("Enter the State of Employee3 : ")
	},  
	{

		"Name" : input("Enter the name of Employee4 : "),
		" dob " : input("Enter the DOB of Employee4 : "),
		"height" :input("Enter the Height of the Employee4 : "),
		"City "  : input("Enter the City of Employee4 : "),
		"State" : input("Enter the State of Employee4 : ")
	},    
	{

		"Name" : input("Enter the name of Employee5 : "),
		" dob " : input("Enter the DOB of Employee5 : "),
		"height" :input("Enter the Height of the Employee5 : "),
		"City "  : input("Enter the City of Employee5 : "),
		"State" : input("Enter the State of Employee5 : ")
	},

}

json_object = json.dumps(emp, indent=4)

print(type(emp))

with open(“Employee.json”, “w”) as outfile:
outfile.write(json_object)

emp1 = open(“Employee.json”)

employee = json.load(emp1)
print(type(employee))
employee1 = list(employee)
print(employee1)
emp1.close()

output is File “e:/ASSSIGNMENT PHYTHON/ASSIGNMENT-6/ASSIGNMENT_6_1.py”, line 8, in
emp = {
TypeError: unhashable type: ‘dict’

please help me out why this error is erecting and how to overcome this…please help
its assignment problem and i am unable to get the output.

@thaseenraza1210
this error occurs when your code tries to hash immutable objects such as a dictionary. The solution to this problem is to convert the dictionary into something that is hashable.

1 Like

Please help me how to execute it

@thaseenraza1210

You have taken input in emp variable…how you are filling the values in that?

Where is the loop running for it

1 Like

To fix this error, you can use square brackets ([]) to create a list of dictionaries instead of curly braces.

i think soo

2 Likes