Lazo Lab Sign up

Python Fundamentals / Loops

Lesson 17 of 38

for loops and range

A for loop goes through each item in a sequence. range(5) gives 0 to 4; range(1, 6) gives 1 to 5.

Key points

  • range(stop) starts at 0
  • range(start, stop) excludes stop
  • range(start, stop, step)
for i in range(1, 6):
    print(i * i)
Watch a video on thisOpens YouTube search results for “for loops and range” in a new tab

Quiz · +10 XP

What numbers does range(3) produce?

Log in to save progress and earn XP.