Mega Code Archive

 
Categories / Python Tutorial / Statement
 

A typical if statement with all three kinds of clauses

x = 2 if x < 0:     print "x is negative" elif x % 2:     print "x is positive and odd" else:     print "x is even and non-negative"