in-place string reversal

Martin P. Hellwig mhellwig at
Tue Mar 28 16:29:08 CEST 2006

Sathyaish wrote:
> And that the "extra-memory" operation I've given above is expensive, I
> believe. Is there an efficient way to do it?
If i recall correctly a string is an immutable list.
I would do it this way:
 >>> strTXT = "foo"
 >>> strREV = strTXT[::-1]
 >>> strREV


More information about the Python-list mailing list