Reverse Iteration Through Integers

Jabba Laci jabba.laci at
Mon Oct 19 07:53:04 CEST 2009


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?



> Here is a simplistic version that doesn't use fancy math:
>>>> str(24)
> '24'
>>>> str(24)[::-1]
> '42'
>>>> int(str(24)[::-1])
> 42

More information about the Python-list mailing list