May 2019
Beginner
528 pages
29h 51m
English
range: A Deeper LookFunction range also has two- and three-argument 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:
In [1]: for number in range(5, 10):...: print(number, end=' ')...:5 6 7 8 9
Function range’s three-argument 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:
In [2]: for number ...Read now
Unlock full access