On Sun, Oct 18, 2009 at 10:53 PM, Jabba Laci <jabba.l...@gmail.com> wrote:
> Hi,
>
> 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?

Specifies the step value, as in:   foo[start:stop:step]

When not specified it, defaults to 1.
So foo[::-1] gives the entire sequence backwards.
Analogously, foo[::2] gives every other item in the sequence, forwards.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to