lundi 25 juillet 2016

Check if statement against each item in a list

I found a similar question here

But the answers don't seem to apply to me.

Here is my code:

y = 3
list1 = [1,2,3,4,5]

if y != 0 or y != list1:
    print("y is not in range")
else:
    print(y)

It keeps printing "y is not in range" .

My goal is to check if y does NOT equal to 0 OR if y does not equal to any item in the list.

Aucun commentaire:

Enregistrer un commentaire