python / beginner
Snippet
Generating Number Sequences with range()
The range() function generates a sequence of numbers, which is commonly used for looping a specific number of times. By default, it starts at 0.
snippet.py
1
2
for i in range(3):print("Count:", i)
Breakdown
1
for i in range(3):
Starts a loop that will run for numbers 0, 1, and 2.
2
print("Count:", i)
Outputs the current number in each iteration.