[Tutor] Tutor Digest, Vol 64, Issue 80

Benjamin Serrato benjamin.serrato at gmail.com
Tue Jun 16 16:15:29 CEST 2009


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_2000 at yahoo.com>
> To: Raj Medhekar <cosmicsand27 at yahoo.com>, Wayne <srilyk at gmail.com>
> Cc: Python Tutor <tutor at python.org>
> Subject: Re: [Tutor] Help Needed
> Message-ID: <689147.52804.qm at 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
>


More information about the Tutor mailing list