A range object is like a list of numbers, though not technically a list. This list of numbers changes based on the parameters given.
range(number) will return a range object with integers from 0 to number - 1
range(number1, number2) will return a range object with integers from number1 to number2 - 1
range(number1, number2, difference) will return a range object starting with number1, and will continue to give numbers using the given difference until reaching number2
Here's a few examples:
range(5) --> (0, 1, 2, 3, 4)
range(7) --> (0, 1, 2, 3, 4, 5, 6)
range(3, 9) --> (3, 4, 5, 6, 7, 8)
range(-3, 3) --> (-3, -2, -1, 0, 1, 2)
range(5, 20, 3) --> (5, 8, 11, 14, 17)
range(10, 5, -1) --> (10 , 9, 8, 7, 6)
In the for loop header, you create a variable called the iterator. This variable changes through each iteration.
You can name this variable whatever you want, but it's good to name it in a way that you know what it is.
for counter in range(5): The iterator is named counter
print( counter ) This will print the value of your iterator each time. (0, 1, 2, 3, then 4)
The reason this loop runs 5 times is that there are 5 total numbers in the range(5) object.