jeudi 2 juin 2016

I cannot understand how the "if" and "or" are working here [duplicate]

This question already has an answer here:

if player[2] != (0 or 4 or 7 or 10 or 30):
    print("hi")
else:
    print("bye")

In my program, player[2] is clearly 7. However, when I run this, it returns "hi" instead of "bye". Why? And how would I go about testing that player[2] is not any of these numbers without writing a separate if statement for each?

Edit: My question is different from the suggested link because as opposed to testing one variable against multiple values, I am trying to test multiple variables against one value.

Aucun commentaire:

Enregistrer un commentaire