Hey guys I have a exam next week, and I need to get better with dictionaries. I have this code and I cant figure out how to go about it. Our class are writing code with python language. version 3 (Python 3)
Like say I have a dictionary, and I want to return true if that dictionary has like two or more keys that refer to the same value and false otherwise.
>>> duplicate({'a': 9, 'b': '9', 'c': 7, 9: True})
False
>>> duplicate({'a': 9, 'b': 9, 'c': 7})
True
'''
I gave it a shot but I dont think its right.
def duplicate(dict1):
for a key, value in dict1.items():
dict1[value] = key
return dict1
like I dont get how to find those two keys VALUES.
please help out I would really appreciate it. Any hint or any solution would be better.