+ 2
How to search the value in dictionary?
4 Réponses
+ 6
Loop over keys and use dict[key] to get the values for comparison
https://code.sololearn.com/cSUh5n218k3Y/?ref=app
+ 3
Dict.values()
0
dictionary = {1:2, 2:3, 3:3}
def searchvalue(n, value):
for key, val in n.items():
if key == value:
print(„ found“, key,“:“,val)
searchvalue(dictionary, 2)