I found a similar question here but the answers don't seem to apply to my issue.
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.
I understand that the above or
should be an and
, I'm specifically interested in how to check in the condition of y
being contained in the list.