lundi 25 mai 2020

Simplifying != if statements

I'm scratching my head trying to find a more compact version of this if statement,

if a != b and a != c:
    foo()

Where all conditions are not boolean.
I could imagine that it would be tedious to write if there were more than 2 conditions to check for.

I also tried:

if a != (b and c):
    foo()

But (b and c) depend on their corresponding bool values rather than comparing equivalence to a.
Thanks in advance for any help.

Aucun commentaire:

Enregistrer un commentaire