What is the best way to loop over a python string backwards?
The following seems a little awkward for all the need of -1 offset:
string = \"trick or
Here is a way to reverse a string without utilizing the built in features such as reversed. Negative step values traverse backwards.
reversed
def reverse(text): rev = '' for i in range(len(text), 0, -1): rev += text[i-1] return rev