×

python · level 1 · unit 5 · lesson 4

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

stops a loop early. skips a turn.

Picture a lift going up a tall building. You ride past each floor, and when you reach yours, you get out. You do not ride to the top. break is getting out: the loop stops straight away.

Some buildings have no floor 13, so the lift skips it and carries on. continue is that skip: Python drops the rest of this turn and jumps to the next one.

Both usually sit inside an if, so they only happen when its condition is True. Any lines after them in the same turn do not run.

for floor in range(10, 16):
    if floor == 13:
        continue
    if floor == 15:
        break
    print("Ding! Floor", floor)

Floor 13 is skipped by continue, and break ends the ride at floor 15.