Skip to content
dreamcode
dreamcode
Back to map
Range loops · Lesson 9 of 44
+15 XP on finish
PYTHON BASICS

Counting with range

The range() function is incredibly flexible. You can tell it where to start and where to stop. Remember, Python stops just before the stop number.

How it reads
range(1, 4) generates numbers starting at 1 and stopping before 4 (1, 2, 3)
print(i) runs once for each of those numbers
Cloud tip: If you call range(stop), it starts at 0. If you call range(start, stop), it starts at start.
main.py
PYTHON
real Python, runs in your browser
CONSOLE
- run your code to see output -