'IF' Syntax For Alternative Conditions

Paul Rubin http
Wed Feb 7 23:17:06 EST 2007


rshepard at nospam.appl-ecosys.com writes:
> 	if cond1:
> 	    if cond2:
> 		do_something.

You can write:
   if cond1 and cond2:
      do_something

> 	if cond1 OR if cond2:
> 	    do_something.

if cond1 or cond2:
   do_something

>   I've tried using the C syntax for OR (||) but python complained. I'm sure
> there's a way to do this rather than using if cond1: elif cond2: both with
> the same code to execute.

Python uses the "and" and "or" keywords for && and ||.



More information about the Python-list mailing list