mystery string code - help!

Uncle Ben ben at greenba.com
Wed Apr 20 12:48:30 EDT 2011


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



More information about the Python-list mailing list