4. Using range() in a for Loop

One of the most common uses of range() is with a for loop.

Example:

for i in range(10):
    print(i)

Output:

0
1
2
3
4
5
6
7
8
9

The loop runs once for every number in the range.