Jul-31-2021, 02:15 PM
(Jul-31-2021, 01:51 PM)deanhystad Wrote: From the documents:
https://docs.python.org/3/library/stdtypes.html#range
Quote:class range(start, stop[, step])In your example the range starts with i = 1 and continues while i < 5. Since it is not specified the step size defaults to 1. This results in i having values [1, 2, 3, 4].
The arguments to the range constructor must be integers (either built-in int or any object that implements the __index__ special method). If the step argument is omitted, it defaults to 1. If the start argument is omitted, it defaults to 0. If step is zero, ValueError is raised.
For a positive step, the contents of a range r are determined by the formula r[i] = start + step*i where i >= 0 and r[i] < stop.
print(list(range(1, 5)))
Output:[1, 2, 3, 4]
Thanks for your document link.