On 06/14/2017 12:18 PM, Sibylle Koczian wrote: > Correct usage would be: > > if myvar == val1 or myval == val2: > or > if myvar in (val1, val2):
Just piling on here to say I find the second form very useful to collect arguments in a "friendly" way, if you don't have a reason to very rigidly constrain them. For example, if you have an on/off type switch in your arguments (or "input()" type calls), you can say something like if myarg in ('T', 't', 'True', 'true', 'Y', 'y', 'Yes', 'yes', '1', 'ON', 'On', 'on'): Since that's getting too long, we can smash the casing: if myarg.lower() in ('t', 'true', 'y', 'yes', '1', 'on'): Of course if you do any serious argument handling, it's better to use something like optparse (and earlier argparse) module so you're not reinventing a wheel which has been massively worked on already. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor