mardi 2 mai 2017

shorthand for and/or in python if statements

Is there a shorthand way to write a comparison in an if statement if you are making the same comparison for multiple values. Just curious if anything like this is possible. Thanks for the help!

a =1
b =1
c =1

if a == 1 and b ==1 and c == 1:
    print('yes')

# It would be nice if you could do this or something like it.
if a,b,c == 1:
    print('this would be easier')

Aucun commentaire:

Enregistrer un commentaire