Is there a way to abbreviate a comparison statement in python so that I don't have to write the whole thing out again? For example, instead of :
a=3
if a==3 or a==2:
print "hello world"
could I do something like: if a==(3 or 2): print "hello world"
I know the above example won't work but is there another way i can achieve the desired effect?
if a in (2, 3):
print "hello world"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With