Let’s say I have the following dictionary in a Python program:
the_dictionary_list = {'Color': ['None', 'Amarillo.png', 'Blanco.png', 'Rojirosado.png', 'Turquesa.png', 'Verde_oscuro.png', 'Zapote.png'], 'Cuerpo': ['None', 'Cuerpo_cangrejo.png'], 'Fondo': ['None', 'Oceano.png'], 'Ojos': ['None', 'Antenas.png', 'Pico.png', 'Verticales.png'], 'Pinzas': ['None', 'Pinzitas.png', 'Pinzotas.png', 'Pinzota_pinzita.png'], 'Puas': ['None', 'Arena.png', 'Marron.png', 'Purpura.png', 'Verde.png']}
How can I verify that the element 'None' exists in every single key from the dictionary above?
>Solution :
all(['None' in v for k, v in the_dictionary_list.items()])
This loops through the dictionary key value pairs and returns a True or False if 'None' is in the value. And then all checks if they are all true if one is false it will return False if all are True it returns true