9951 explained code solutions for 126 technologies


pythonHow to find key in dict by value


found_key = list(my_dict.keys())[list(my_dict.values()).index('needle')]ctrl + c
found_key

key of the found value

my_dict

dict to search key by value in

keys()

returns list of dict keys

values()

returns list of dict values

index(

return index of found element in list

list(

convert specified argument to list