This range()
function returns a list of arithmetic progressions or numbers.
range(start, stop[, step])
Here,
Note: The full form returns a list of plain integers [start, start + step, start + 2 * step, …]. If step is positive, the last element is the largest start + i * step less than stop; if step is negative, the last element is the smallest start + i * step greater than stop. the step must not be zero (or else ValueError is raised).
>>> x = range(10)
>>> for i in x:
... print(i)
...
0
1
2
3
4
5
6
7
8
9
>>> x = range(1, 11)
>>> for i in x:
... print(i)
...
1
2
3
4
5
6
7
8
9
10
>>> x = range(1, 0)
>>> for i in x:
... print(i)
...
>>>
>>> x = range(1, 11, 2)
>>> for i in x:
... print(i)
...
1
3
5
7
9
>>> x = range(1, -11, -2)
>>> for i in x:
... print(i)
...
1
-1
-3
-5
-7
-9