Checkpoint

Checkpoint: Night Patrol

Night falls on Emberreach, and Pip patrols the harbour with a lantern. Each patrol hour burns 2 oil. Every 3rd hour, Pip rests instead and uses no oil. If there are fewer than 2 oil left, the patrol must end.

This checkpoint uses the whole chapter: for and range, %, continue, break and adding up as you go.

Assignment

Inside the loop, do these checks in this order:

  1. If hour is a multiple of 3 (hour % 3 == 0), skip this hour with continue.
  2. If oil is less than 2, print Out of oil at hour 8! (with the real hour, using an f-string). Then stop the loop with break.
  3. Otherwise, take 2 from oil, add 1 to patrols, and print Hour 1: patrol (with the real hour).

Keep the last print line. With the starting values, the output should be:

Hour 1: patrol
Hour 2: patrol
Hour 4: patrol
Hour 5: patrol
Hour 7: patrol
Out of oil at hour 8!
Patrols: 5, oil left: 1