Mega Code Archive

 
Categories / Python Tutorial / Statement
 

Using an if-else statement

x, y = 4, 3 if x < y:      smaller = x else:      smaller = y print smaller smaller = (x < y and [x] or [y])[0] print smaller smaller = x if x < y else y print smaller