Complete the Python for Loop
Fill in the BlankBeginner
Question
Fill in the blank so the loop prints 0, 1, 2, 3, 4 (each on its own line).
Code
for i in ___(5):
print(i)
Hint
The built-in function that generates a sequence of numbers is called...
Explanation
The range(5) function generates the sequence 0, 1, 2, 3, 4. The for loop iterates over each value, so print(i) outputs each number on its own line. The completed line is for i in range(5):
Related Resources
Related Lessons
- Conditions and Loops
Learn about Python for loops and range().
Related Cheatsheets
- Python Cheatsheet
Quick reference for Python loops and range().
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.