You can use the slicing operator to change the string:
s = "hello, world" s = s[::-1] print s # prints "dlrow ,olleh"
To convert an integer to a string, reverse it and convert back to an integer, you can do:
x = 314159 x = int(str(x)[::-1]) print x
Adam rosenfield
source share