So this is related to a shorter question posted here earlier: Get key by value in dictionary
I adapted the example that the values be list
s of int
. Say I had this,
mydict = {'george':[1,2,3],'amber':[18,19]}
then I could output "amber"
by:
print(list(mydict.keys())[list(mydict.values()).index([18,19])])
Is there a way to adjust this so I can output "amber"
by "asking" for just one item of the list? i.e. e.g. 19
?
Summary: I want to ask my dictionary: "Give me the key that has in its value(list) the item "19"