Mega Code Archive

 
Categories / Python Tutorial / Statement
 

The if statement is used for conditional execution, and it may include elif and else clauses

x = 2 if x < 10:     print 'Less than ten' elif 10 <= x < 20:     print 'Less than twenty' else:     print 'Twenty or more'