0Pricing
Mojo Academy · Lesson

Iterating with for and range

Walk over numbers and sequences.

Walk Over Items

When you want to visit each value in turn, reach for a for loop. It pulls one item at a time and runs the body for each. 🚶

The for Shape

Write for, a loop variable, the word in, something to walk over, then a colon and an indented block.

for item in things:
    print(item)

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