if/else Statement¶
The if
statement can be extended with a code block that gets executed if the
expression evaluates to False
by adding an else
statement.
if condition:
CODE_BLOCK
else:
ELSE_CODE_BLOCK
Example:
def ask_computer(a, b):
if a > b:
print("Computer says no")
else:
print("Computer says yes")
ask_computer(1, 2)
ask_computer(3, 2)