← All sections

Module 3 · Boolean values, conditional execution, loops, lists and list processing, logical and bitwise operations

Loops in Python

The heart of the language's name: code that repeats. while and for loops, the range() function, and the break and continue controls that steer them.

Begin lesson 1 →
  1. 1The while loopRepeat a block as long as a condition stays True — plus while/else.
  2. 2Infinite loopswhile True, the loops that never stop, and how to escape them.
  3. 3The range() functionGenerate sequences of numbers — start, stop and step.
  4. 4break and continueBail out of a loop early, or skip straight to the next round.
  5. 5The for loopStep through every item in a sequence — plus for/else.
  6. 6QuizCheck your understanding of while, for, range and loop control.