Super Easy Way to Reverse a String in Python

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.

One Response to “Super Easy Way to Reverse a String in Python”

  1. [...] Saw this easy way to reverse a string in python today, over at Answer My Searches [...]