Reverse a string in Python

To reverse a string, make a slice with a negative step value:

print "abcd"[::-1]

You might be tempted to use reversed(), but this returns an iterator, so you need to join() it to make a string again:

print "".join(reversed("abcd"))