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 treat"
for i in range(len(string)-1, 0-1, -1):
print string[i]
The following seems more succinct, but is it actually generate a reversed string so that there is a minor performance penalty?
string = "trick or treat"
for c in string[::-1]:
print c