0

Play this code and read output. I asked my question there.

https://code.sololearn.com/cDqrYyXzO98k/?ref=app

13th Jul 2019, 6:07 PM
MR Jey
MR Jey - avatar
3 Respostas
+ 2
lst = [k for k,v in dic.items() if v == "10"] print(lst) # ['A']
13th Jul 2019, 7:46 PM
Diego
Diego - avatar
+ 1
Remember the keys in a dictionary are unique. The values don't have to be. Using dict.get() works because if the key is there, there will only be one corresponding value. It doesn't work the other way around. E.g. dicA = {Jim: male, Jane: female, Jack: male, Joe: male} You can't input "male" and extract just one name, because there are three.
15th Jul 2019, 1:14 AM
David Ashton
David Ashton - avatar
0
Just change line 2 like this: dic ={"A": "10", "10":"A"}
13th Jul 2019, 6:11 PM
ΛM!N
ΛM!N - avatar