Module 2

elif

Checking multiple conditions in order.

More than two paths

When you need more than two paths, use elif (short for else if). Python checks each condition in order and runs the first one that is true.

Python
score = 75
if score >= 90:
    print("Excellent")
elif score >= 70:
    print("Good")
else:
    print("Keep practicing")
Good

Python checks the conditions from top to bottom. The first true condition wins. The else at the end catches everything else.

Your task

Use elif

  • If score is 75: print Excellent (>= 90), Good (>= 70), or Keep practicing.