Python · Stage 3 – Making Decisions · Lesson 20 of 50

if Statements

Run an indented instruction only when one condition is True.

age = 14
if age >= 13:
    print("Teen account")
Line-by-line explanation
  1. The first line stores the age.
  2. The if line checks whether age is at least 13.
  3. The colon : begins the controlled block.
  4. Four spaces indent the print line, showing it belongs to the if statement.