[Python-ideas] [Python-Dev] Inclusive Range

Hallvard B Furuseth h.b.furuseth at usit.uio.no
Fri Oct 8 16:10:35 EDT 2010


Jed Smith <jed at jedsmith.org> writes:
>>>> a = [1, 2, 3, 4, 5, 6]
>>>> a[::-1]
> [6, 5, 4, 3, 2, 1]

Nice.  Is there a trick to get a "-0" index too?
Other than doing 'i or len(L)' instead of 'i', that is.

>>> L = [1,2,3,4,5]
>>> L[2:-2], L[2:-1], L[2:-0]  # not quite right:-)
([3], [3, 4], [])

-- 
Hallvard



More information about the Python-list mailing list