Skip to content
dreamcode
dreamcode
Back to map
Elif chains · Lesson 5 of 44
+15 XP on finish
PYTHON BASICS

Multiple choices

When you have more than two possibilities, use elif (short for else-if) to check additional conditions. Python checks them in order and runs the first one that is True.

How it reads
if hour < 12: is checked first
elif hour < 18: is checked only if the first condition was False
else: runs if none of the conditions above were True
Cloud tip: You can have as many elif blocks as you need, but you can only have one if at the start and one else at the end.
main.py
PYTHON
real Python, runs in your browser
CONSOLE
- run your code to see output -