Ah, this makes sense at some wacky level.
Consider this array (language doesn't matter here, so this is pseudo-code):
array = ('a', 'b', 'c', 'd', 'e')
Some languages use a convention where begin(array) is equivalent to array[0], and end(array) is equivalent to array[5], or one past the last element. A loop in such a world might be written like this:
for (x = 0; x != end(array); ++x)
do_something(array, x);
The notation used for such a concept is sometimes this:
[0,5)
...meaning (0 <= x < 5). This concept and notation is common in C++. And is used by Python's range() function.
Python's range method has the following semantics:
range(stop) # 0 .. stop-1
range(start,stop) # start .. stop-1
range(start,stop,step) # start .. stop-1 by step: for(ix=0; ix != sto
+p; ix += step) {...}
In each case start is inclusive, and stop is exclusive. [start,stop) in mathematical notation, or this: (start <= x < stop).
|