range(start,stop)

Skip Montanaro skip at mojam.com
Fri Feb 11 16:16:15 EST 2000


    Stephane> What the interest for the range function to stop at stop-1 and
    Stephane> not at stop ?

Well, unless you made a mistake in your message, it does what you ask
already:

    >>> print range(0,9)
    [0, 1, 2, 3, 4, 5, 6, 7, 8]

If what you really meant was why doesn't range(start, stop) include stop in
its output, that has to do with consistent modulo arithmetic.  Others can
describe it better.  You might try searching the list archives.  I'm fairly
certain Tim Peters or GvR have expounded on this topic before.

Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/
"Languages that change by catering to the tastes of non-users tend not to do
so well." - Doug Landauer




More information about the Python-list mailing list