#reverse dictionary with multiple value(duplicate key) by Kanha
mydict = {
'1': 'kanha',
'2': 'satyam',
'3': 'kanha'
}
def reverse_dict(mydict):
v={}
for x,y in mydict.items():
if y not in v:
v[y]=[x]
else:
v[y].append(x)
return v
print(reverse_dict(mydict))
0 Comments