0Pricing
Mojo Academy · Lesson

Looping with while

Repeat until a condition changes.

Repeat Until Done

Sometimes you must run code again and again. A while loop repeats its block as long as a condition stays true. 🔁

The while Shape

Write while, a condition, a colon, then an indented block. Mojo rechecks the condition before every pass through the body.

while count < 3:
    print(count)

All lessons in this course

  1. Making Choices with if/else
  2. Looping with while
  3. Iterating with for and range
  4. break, continue, and Early Exit
← Back to Mojo Academy