Wayne already explained slicing but I would like to point out the
digit after the second colon changes the default step of the slice.
Usually it defaults to 1, here because no values were given it takes
the entire string and steps backward.  You could set it to 2.

First digit, beginning of slice, second digit end of slice, third
digit is the jump to the next item in the sequence.

HTH,
Ben S.


> Message: 2
> Date: Mon, 15 Jun 2009 23:53:03 -0700 (PDT)
> From: Gil Cosson <gilcosson_2...@yahoo.com>
> To: Raj Medhekar <cosmicsan...@yahoo.com>, Wayne <sri...@gmail.com>
> Cc: Python Tutor <tutor@python.org>
> Subject: Re: [Tutor] Help Needed
> Message-ID: <689147.52804...@web35602.mail.mud.yahoo.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> I just stumbled on this
>
> Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] 
> on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> s="hello world"
> >>> s=s[::-1]
> >>> print s
> dlrow olleh
> >>>
>
> ---
>
> Gil Cosson
>
> Bremerton, Washington
>
> 360 620 0431
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to