I would like to be able to find a key within a dictionary by means of a value entered. The example is as follows.
diccionario = {'jorge' : 1, 'andrea' : 4}
buscar = int(input("Introduce numero: "))
for nombre, numero in diccionario.items():
if numero == buscar:
print(nombre)
The previous example works correctly, we introduce a number and if it matches a value of one of the keys that are inside the dictionary it returns the name of the key, but if instead of a value I assign several values to each one of the keys by means of a list like for example the following case.
diccionario = {'jorge' : [1,2,3] , 'andrea' : [4,5,6]}
buscar = int(input("Introduce numero: "))
for nombre, numero in diccionario.items():
if numero == buscar:
print(nombre)
The same procedure does not work, it does not return anything.
Well this would basically be my question I hope that someone can help me with this question in advance thank you very much.