How does the range( ) function work?
range() function’s three different versions give us all kinds of options for generating ranges of numbers.
range(stop)generates a range of numbers from 0 up to the
stoppoint. It does not include the stop number. So writing
[0, 1, 2].
3is not included.
range(start, stop)does the same thing, but now we can specify a starting value. The
stopis still not included, but start is included. If we have
range(0, 3), it produces the same result as above. This is useful when we don’t want to start at
range(start, stop, step)works mostly like the above, where
stopis excluded, and now we have another parameter to work with:
steptells it by how much to change in value each time. For example, writing
range(0, 10, 2)give us
[0, 2, 4, 6, 8]because we
10(not included), and