Source Code:
(back to article)
def get_key(dictionary, value): for key, val in dictionary.items(): if val == value: return key return None my_dict = {'a': 1, 'b': 2, 'c': 3} print(get_key(my_dict, 2)) # Output: 'b'
Result:
Report an issue