Reversing a string

Jay Loden python at jayloden.com
Sun Jul 1 23:08:02 EDT 2007


Alex Martelli wrote:
> since what you're doing is...:
> 
>>>> s = "onomatopoeia"
>>>> s = s.join(s[::-1])
>>>> s
> 'aonomatopoeiaionomatopoeiaeonomatopoeiaoonomatopoeiaponomatopoeiaoonoma
> topoeiatonomatopoeiaaonomatopoeiamonomatopoeiaoonomatopoeianonomatopoeia
> o'
> 
> ...which isn't really just reversing the string, but quite a bit more
> work!-)

That's what I get for copying and pasting from the post preceding mine and not actually checking it for what it does ;)



More information about the Python-list mailing list