Answers for "find key using value in dictionary python"

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

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
0

get a value using a dictionary key in python

print(d.get('key5', 'NO KEY'))
# NO KEY

print(d.get('key5', 100))
# 100
Posted by: Guest on November-10-2021

Code answers related to "find key using value in dictionary python"

Python Answers by Framework

Browse Popular Code Answers by Language