>_BeginnerCoder
Donate

Lesson 5 — Loops

Repeating work

A for loop runs the same block once for each item in a sequence. range(5) produces 0, 1, 2, 3, 4 — note it stops before 5.

Why it matters: loops let you process a list of any size in a few lines instead of copying code over and over.

Tip: to count 1 to 10, use range(1, 11) — the start is included, the end is not.

Task

Print the numbers 1 to 10.

← Back
Next →

Enjoying this lesson? Share it 👇

Keep going with Python Foundations

Ready for more? These paid resources pick up where this lesson leaves off.

Some links on this page are affiliate links: we may earn a commission at no extra cost to you. We only recommend tools we believe are genuinely useful.