CurriculumPython if, elif and else for Kidselif and else

Python elif and else: Chains of Decisions Explained

Chains of decisions — and why the ORDER and the KIND of check both matter.

Lesson 3 of 5PROAges 10+
See what PRO unlocks →

elif and else

You know if. Now let's chain several questions together, and add a catch-all for everything else.

elif means 'otherwise, if THIS is true' — it only gets checked if everything above it was False.

gold = 150
if gold >= 100:
    print("So generous!")
elif gold > 0:
    print("Thank you.")

Output

So generous!

else is the catch-all at the end — no condition of its own, it just catches whatever nothing else matched.

gold = 0
if gold >= 100:
    print("So generous!")
elif gold > 0:
    print("Thank you.")
else:
    print("...")

Output

...

Here's the important part. An elif chain STOPS at the first True — even if a later condition would ALSO be true.

strength = 90
if strength > 80:
    print("Legendary!")
elif strength > 50:
    print("Strong.")

Output

Legendary!

90 is more than 50 too — but you never see 'Strong', because elif already stopped at Legendary. Only one branch ever runs.

Compare that to two SEPARATE ifs — those don't stop each other. Both can fire on the same number.

strength = 90
if strength > 80:
    print("Legendary!")
if strength > 50:
    print("Strong.")

Output

Legendary!
Strong.

Check your understanding

strength = 90. Which of these will print BOTH Legendary and Strong?

  • Two separate if statements
  • if / elif
  • Neither — they always do the same thing

Why: Two separate ifs check independently, so both can fire on the same value: Legendary AND Strong. if/elif is a CHAIN — it stops at the first match, so only Legendary prints. They agree on most values, but not on this one, which is exactly why the difference matters.

gold = 0. What does the else branch need for its OWN condition to run?

if gold >= 100:
    print("So generous!")
elif gold > 0:
    print("Thank you.")
else:
    print("...")
  • Nothing — else has no condition of its own
  • else needs its own comparison, like else gold == 0:
  • else only works if there was exactly one elif before it

Why: else takes no condition of its own — writing else gold == 0: is actually a Python error. It runs automatically whenever nothing above it matched.

What you'll practice

Bring the dragon gold. 100 or more: it calls you generous. Less than 100 but more than 0: it says thanks. Nothing at all: it looks disappointed. You brought 150 gold.

Unlock this lesson with PRO →

More from this topic

elif and else is one lesson inside Python if, elif and else for Kids — see the full lesson order and what the whole topic covers.

View the full topic →