if / elif / else (Python)
if, elif, and else let a Python program choose between different blocks of code based on whether conditions are True. elif checks another condition only if the earlier ones were False.
Python
Syntax
if condition:
...
elif other_condition:
...
else:
...Examples
Python
score = 75
if score >= 90:
print("A")
elif score >= 70:
print("B")
else:
print("C")Output:
B