Here’s what I discoved today. To reverse a string in Python you just do:
text[::-1]
It’s that easy! Here is a more filling example:
>>> text='greg'
>>> print text[::-1]
gerg
And finally here is why it works, for the curious.
Posted by Greg Pinero (Primary Searcher) in Python
RSS 2.0