On Sun, 18 Oct 2009 23:04:36 -0700 (PDT),
alex23 <[email protected]> wrote:
> On Oct 19, 3:53 pm, Jabba Laci <[email protected]> wrote:
>> Would someone explain how str[::-1] work? I'm new to Python and I only
>> saw so far the str[begin:end] notation. What is the second colon?
>
> Slice notation is of the form [start:stop:step]. start defaults to the
> start of the sequence, stop to the end, and step to 1.
>
> So a slice of [::-1] returns the full sequence in reverse, stepping
> back one character at a time from the end of the sequence to the
> beginning.
>
> The only mention I could find was
> http://docs.python.org/dev/3.0/library/functions.html#slice
There's also
http://docs.python.org/reference/datamodel.html#index-791
Martien
--
|
Martien Verbruggen | There are only 10 types of people in
[email protected] | the world; those who understand binary
| and those who don't.
--
http://mail.python.org/mailman/listinfo/python-list