Contact: aviboots(AT)netvision.net.il
39,009 questions
50,723 answers
573 users
dict = {'key1':34, 'key2':89, 'key3':12, 'key4':72, 'key5':90} list_of_keys = list(dict.keys()) list_of_values = list(dict.values()) index = list_of_values.index(12) print(list_of_keys[index]) ''' run: key3 '''
def get_key(val): for key, value in dict.items(): if val == value: return key return "value not exist" dict = {'key1':34, 'key2':89, 'key3':12, 'key4':72, 'key5':90} print(get_key(12)) ''' run: key3 '''