Reverse Iteration Through Integers

Martien Verbruggen martien.verbruggen at invalid.see.sig
Mon Oct 19 16:42:45 EDT 2009


On Sun, 18 Oct 2009 23:04:36 -0700 (PDT),
	alex23 <wuwei23 at gmail.com> wrote:
> On Oct 19, 3:53 pm, Jabba Laci <jabba.l... at gmail.com> 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
first.last at heliotrope.com.au | the world; those who understand binary
                             | and those who don't.



More information about the Python-list mailing list