← back to unit
Easy
# basics conditionals
if / else
Add an else to run different code when the condition is False, instead of running nothing:
age = 10
if age >= 18:
print("Adult")
else:
print("Minor")
Exactly one of the two branches always runs.
Your turn: read a number age. Print Adult if age is 18 or more, otherwise print Minor.
💡 need a hint?
pyb-cond-if-else.py🔒 given lines are locked — write your code in between
loading...