Disclaimer: I am not asking if the upper-boundknow that when I use stoprange([start], stop[, step])argument of or slice([start], stop[, step])and, the range()stop value is exclusive or hownot included to use these functionsin the range or slice.
Calls to theBut rangeandwhy does it work this way?
Is it so that e.g. a slicerange(0, x)functions, as well as the slice notation or [start:stop]range(x) all refer to sets of integers.
range([start], stop[, step])
slice([start], stop[, step])
In all these, thewill contain stopx integer is excluded.
I am wondering why the language is designed this way.many elements?
Is it to makefor parallelism with the C for loop idiom, i.e. so that for i in range(start, stop):equal to the number of elements in the represented integer set when superficially resembles for (i = start ; i < stop; i++) { equals 0 or is omitted?
Is it to have:
for i in range(start, stop):
look like the following C code?See also Loop backwards using indices for a case study: setting the stop and step values properly can be a bit tricky when trying to get values in descending order.
for (i = start ; i < stop; i++) {