>_BeginnerCoder
Donate

Lesson 4 — if / else

Making decisions

if runs a block only when a condition is true; else covers every other case. A condition is any expression that is True or False, like age >= 18.

Why it matters: decisions are how programs react differently to different data instead of always doing the same thing.

Watch out: in Python the indented spaces under if and else are not decoration — they define which lines belong to each branch.

Task

Change age and make it print adult only when age is 18 or more.

← Back
Next →

Enjoying this lesson? Share it 👇

Keep going with Python Foundations

Ready for more? These paid resources pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. We only recommend tools we believe are genuinely useful.