The elif keyword (short for "else if") lets you check multiple conditions in sequence. Python evaluates each condition from top to bottom and executes only the first branch whose condition is True — all remaining branches are skipped. You can chain as many elif blocks as you need between the initial if and the final else. This makes elif perfect for situations where you need more than two possible outcomes, like grading systems, menu selections, or categorizing data into multiple groups.
Key Points
elif is short for "else if" — it adds extra conditions to check.
Python checks conditions top-to-bottom; the first True branch runs.
You can have as many elif branches as needed.
Only one branch ever executes in an if/elif/else chain.
The else block at the end is optional — it catches everything else.
Each elif needs its own condition and a colon (:).
Order matters: place more specific conditions before general ones.