Back Navigation Next Navigation Conceptual Review (page 25 of 55)

Python also supports the chaining of an if-elif-else statement when there are more than two options. That is, we may need more than the two branches that are associated with if-else statements. One way to do this is by chaining conditionals using "elif" clauses. An elif clause has its own Boolean expression. There is no limit to the number "elif" clauses that may be used.

Conditionals

if: The first condition checked. If it's True, the code inside the if block runs, and the rest of the conditions are skipped.
elif: Stands for "else if." If the if condition is False, Python checks each elif condition in order. The first one that's True will execute its block of code.
else: If none of the conditions (if or elif) are True, the code in the else block is executed.