BUILT-IN FUNCTION RANGE: A DEEPER LOOK
Function range also has two and threeargument versions. As you’ve seen, range’s one-argument version produces a sequence of consecutive integers from 0 up to, but not including, the argument’s value. Function range’s two-argument version produces a sequence of consecutive integers from its first argument’s value up to, but not including, the second argument’s value, as in:
...: print(number, end=' ')
...:
5 6 7 8 9
Function range’s threeargument version produces a sequence of integers from its first argument’s value up to, but not including, the second argument’s value, incrementing by the third argument’s value, which is known as the step:
...: print(number, end=' ')
...:
0 2 4 6 8
If the third argument is negative, the sequence progresses from the first argument’s value down to, but not including the second argument’s value, decrementing by the third argument’s value, as in:
...: print(number, end=' ')
...:
10 8 6 4 2