June 2017
Beginner
352 pages
8h 39m
English
Range also supports a step argument:
>>> list(range(0, 10, 2))[0, 2, 4, 6, 8]
Note that in order to use thestep argument, we must supply all three arguments. Range is curious in that it determines what its arguments mean by counting them. Providing only one argument means that the argument is the stop value. Two arguments are start and stop, and three arguments are start, stop and step. Python range() works this way so the first argument, start, can be made optional, something which isn't normally possible. Furthermore the range constructor doesn't support keyword arguments. You might almost describe it as unPythonic!
The arguably unPythonic constructor for range, where the interpretation of the arguments depends on whether ...
Read now
Unlock full access