Open workspace
Python 2.1Code walkthrough9 parts

if, elif and else

Make the program choose.

Loading your progress…

In this lesson9 parts

  1. 01Choosing with if: a weekend check that is always true
  2. 02The if statement: the condition, the colon and the indented block
  3. 03Indentation, IndentationError and the missing colon
  4. 04else and elif: two branches, and more than two
  5. 05The conditional expression: if and else in one line
  6. 06Truthiness: which values count as True, and the weekend check explained
  7. 07The order of elif, separate if statements, and nesting
  8. 08match and case for fixed values, and the capture pattern mistake
  9. 09Recap and your challenge