Suppose I have two dictionaries as such dict1 and dict2 and I wish to compare the keys of both dictionaries and if both are the same, plan on switching the value of the second dictionary to the key of the first dictionary. I came up with the following code:
dict1 = {"1|1":["xyx","zzz","zxz"],"1|2":["aa","xaa","bli"],"1|3":["jjj","kkk"]}
dict2 = {"1|1":{"hum1":"hum2"},"1|2":{"hum3":"hum4"},"1|4":{"hum5"}}
new_dict = {}
for k,v in dict1.items():
for m,n in dict2.items():
if(k==m):
#new_dict[n] = v
new_dict.update({n: v})
print(new_dict)
##new_dict = {{"hum1":"hum2"}:["xyx","zzz","zxz"],{"hum3":"hum4"}:["aa","xaa","bli"]} expected output
I stumble upon the error: unhashable type: 'dict'
What might I be doing wrong here?