Starlit Daily

📚 › Python: the friendliest first language

8. Loops with for and range

A for loop goes through each item of a sequence. range(5) produces 0, 1, 2, 3 and 4: it starts at zero and stops before 5.

range(1, 6) gives 1 to 5.

Show example

for n in range(1, 4):
    print("Count", n)

✍️ Your turn

Print the numbers 1 to 5, one per line, using range.

← Back to course