invert the order of a string
Paul Rubin
http
Mon Feb 13 19:39:38 EST 2006
rtilley <rtilley at vt.edu> writes:
> Well, it turns out to be the best way to invert a string, IMO. The
> reversed() feature returns a reversed object... not a reversed
> string. In short, I have to fool with it again _after_ it has been
> inverted. The slicing takes care of the job right away and gives me
> what I want... no Computer Sciencey <reversed object at 0xb6f6152c>>
> to deal with :)
Oh, I see. I thought I'd tested reversed(...) but I guess I didn't.
I'm going senile. reversed makes an iterator.
Anyway, slicing is one solution; the array module is another.
More information about the Python-list
mailing list