Reverse Iteration Through Integers

Jabba Laci jabba.laci at gmail.com
Mon Oct 19 01:53:04 EDT 2009


Hi,

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?

Thanks,

Laszlo

> 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