[Tutor] "Philosophical" question about string slicing from end of a string

eryksun eryksun at gmail.com
Tue Nov 25 06:43:46 CET 2014

On Mon, Nov 24, 2014 at 1:33 PM, Zachary Ware
<zachary.ware+pytut at gmail.com> wrote:
> Also note that there's no way to get the last member with a negative
> second index.

Also note that, given a -1 step, there's no way to get the first
member with a non-negative second index.

    >>> s[-1:0:-1]

It requires a negative index that's at least one less than the
negative index of the first member:

    >>> s[-1:-len(s)-1:-1]

If possible, leave this implicit in the slice:

    >>> s[::-1]

More information about the Tutor mailing list