if Statements

>>> x = int(input("Please enter an integer: "))
Please enter an integer: 42
>>> if x < 0:
...     x = 0
...     print('Negative changed to zero')
... elif x == 0:
...     print('Zero')
... elif x == 1:
...     print('Single')
... else:
...     print('More')
...
More

An if … elif… elif … sequence is a substitute for the switch or case statements found in other languages.

if Statements — Structure map

Clickable & Draggable!

if Statements — Related pages: