StudyToCert

All certifications / PCEP / Lessons

PCEP – Certified Entry-Level Python Programmer PCEP-30-02 · Domain 2: Control flow: conditional blocks and loops

For loops over range() with start, stop and step, including negative steps and empty ranges

▶ Watch the overview video

Last reviewed September 30, 2026 · Leer en español

A for loop runs its body once for each item in a sequence. To repeat something a known number of times, you usually loop over range(), which produces a series of integers on demand without building a list in memory. The loop variable takes each value in turn, and you can use it inside the body.

Free account

Keep reading for free

Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.

Sign up free Log in

Study PCEP for free
A week-by-week plan with every lesson, quizzes, checkpoint tests, a practice exam and hands-on labs.
Open the PCEP study plan