Python if...else Statement ΒΆ

An if statement can have an optional else clause.
The syntax of if...else statement is:
if condition:
# block of code if condition is True
else:
# block of code if condition is False

Note

The if...else statement evaluates the given condition:
If the condition evaluates to True,
the code inside if is executed
the code inside else is skipped


If the condition evaluates to False,
the code inside else is executed
the code inside if is skipped