Keywords and Control Flow

elif — Additional conditional branch

Add another condition to an existing if chain. Python reaches an elif only when every earlier condition was false. Multiple elif clauses are allowed; none may follow the final else. Unlike a series of independent if statements, the chain cannot select multiple branches during one execution.

Formal Syntax & Structure

python syntaxpython
if condition:    suiteelif other_condition:    suite

Working Example

Example Snippetpython
score = 72if score >= 90:    print("excellent")elif score >= 60:    print("pass")else:    print("retry")
Python Reference