Null dictionary

Hi,
I am trying to print a dictionary but some values are empty and those who are empty, in stead of printing ‘None’ I do not want it to print anything.

This is what I wrote, but it still prints ‘None’, could someone help me please?

    for randoms in random['drinks']:
        print(randoms['strDrink'])
        print(randoms['strAlcoholic'])
        print('GLASS: ', randoms['strGlass'])

        for x in range(1, 15):
            y = randoms['strIngredient{}'.format(x)]
            if y == 'None':
                pass
            else:
                print(y)

You are checking for equality to the string “None”.

To check for None, use:
if y is None:

edit: a simpler solution would be:

if y is not None:
    print(y)
1 Like

Thank you so so much!!!