Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #3728

mystery string code - help!

From Uncle Ben <ben@greenba.com>
Newsgroups comp.lang.python
Subject mystery string code - help!
Date 2011-04-20 09:48 -0700
Organization http://groups.google.com
Message-ID <801e7013-ac1f-4b77-9783-dfdfd5b86149@cu4g2000vbb.googlegroups.com> (permalink)

Show all headers | View raw


I found this in one of the online cookbooks:

#Raghunath Reddy Peesari 6 years, 3 months ago  # | flag
#There is more simple way. ###

a = 'abcdefghi'
a = a[::-1]

print a

>>> 'ihgfedcba'

As a newbie Pythoner, I understand [] -1]
but would some tell me how '::' does its magic?

Uncle Ben

Back to comp.lang.python | Previous | NextNext in thread | Find similar


Thread

mystery string code - help! Uncle Ben <ben@greenba.com> - 2011-04-20 09:48 -0700
  Re: mystery string code - help! Dan M <catdude@gmail.com> - 2011-04-20 17:01 +0000
    Re: mystery string code - help! Uncle Ben <ben@greenba.com> - 2011-04-20 17:58 -0700

csiph-web