Answers for "search dictionary for value python"

3

search in dict python

dictionary = { "key1" : 1, "name" : "Jordan", "age" : 21 }
for key in dictionary.keys():
    print("the key is {} and the value is {}".format(key, dictionary[key]))
    # or print("the key is",key,"and the value is",dictionary[key])
# OUTPOUT
# the key is key1 and the value is 1
# the key is name and the value is Jordan
# the key is age and the value is 21
Posted by: Guest on October-10-2020
0

find value in dictionary python

k = {1:10,2:20,3:30,4:40}
#idea : print([5,6,7,8][[12,15,47,45].index(15)])
b = list(k.keys())[list(k.values()).index(20)] #find index of 20 => return 2
Posted by: Guest on September-10-2021
-3

find key by value python

print(list(d.keys())[list(d.values()).index(990)])
Posted by: Guest on May-04-2020

Code answers related to "search dictionary for value python"

Python Answers by Framework

Browse Popular Code Answers by Language