Confessions of a Python fanboy

superpollo user at example.net
Thu Jul 30 14:30:45 EDT 2009


MRAB wrote:
> superpollo wrote:
...
>> how to reverse a string in python? must i usa a temp? like:
>>
>>  >>> s = "ciccio"
>>  >>> l = list(s)
>>  >>> l.reverse()
>>  >>> s = "".join(l)
>>  >>> s
>> 'oiccic'
>>  >>>
>>
>> ???
>>
> Use slicing with a step of -1:
> 
>  >>> s = "ciccio"
>  >>> s[::-1]
> 'oiccic'

lol

bye



More information about the Python-list mailing list