python / beginner
Snippet
Generating Sequences with range()
The range() function generates a sequence of numbers, starting from 0 by default. It is commonly used to run a loop a specific number of times.
snippet.py
1
2
for i in range(3):print(i)
Breakdown
1
for i in range(3):
Create a loop that iterates over a sequence of numbers from 0 to 2.
2
print(i)
Output the current number of the sequence to the console.