Answers for "get key of dictionary python using value"

5

how to get key of a particular value in dictionary python using index

mydict = {'george': 16, 'amber': 19}
print(list(mydict.keys())[list(mydict.values()).index(16)])  # Prints george
Posted by: Guest on June-21-2020
0

dict ;get a key of a value

myDict={"name":"PythonForBeginners","acronym":"PFB"}
print("Dictionary is:")
print(myDict)
dict_items=myDict.items()
print("Given value is:")
myValue="PFB"
print(myValue)
print("Associated Key is:")
for key,value in dict_items:
    if value==myValue:
        print(key)
Posted by: Guest on October-24-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 "get key of dictionary python using value"

Python Answers by Framework

Browse Popular Code Answers by Language