Python course · Chapter 7

Loops that wait

while loops, checking input, stopping with break.

Project: guess the number.

  1. 7.1Repeating with whileA while loop keeps going as long as something is True, however many times that takes.6 steps · about 20 minutes · 0 of 3 challenges passedStart →
  2. 7.2Checking inputKeep asking until the user types something sensible. This is called validation.6 steps · about 20 minutes · 0 of 3 challenges passedOpen →
  3. 7.3Stopping with breakbreak jumps straight out of a loop, so a loop can stop in the middle when something happens.6 steps · about 20 minutes · 0 of 3 challenges passedOpen →
  4. 7.4For or while?Use for when you know how many times; use while when you're waiting for something to happen.5 steps · about 20 minutes · 0 of 3 challenges passedOpen →
  5. 7.5Project: guess the numberPut the chapter together: a guessing game that says higher or lower and counts your guesses.5 steps · about 20 minutes · 0 of 3 challenges passedOpen →
  6. CheckCheckpointFive mixed questions on while loops, validation and break, with earlier chapters mixed back in. Pass them all to finish the chapter.1 steps · about 15 minutes · 0 of 5 challenges passedOpen →