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
Python 3 with enumerate and reversed methods:
enumerate
reversed
string = "trick or treat" for i, c in enumerate(reversed(string)): print(i, c)
You can use print(c) just for retrieving each character without the index.