Best way to loop over a python string backwards

EDIT: It has been quite some time since I wrote this answer. It is not a very pythonic or even efficient way to loop over a string backwards. It does show how one could utilize range and negative step values to build a value by looping through a string and adding elements in off the end of the string to the front of the new value. But this is error prone and the builtin function reversed is a much better approach. For those readers attempting to understand how reversed is implemented, take a look at the PEP, number 322, to get an understanding of the how and why. The function checks whether the argument is iterable and then yields the last element of a list until there are no more elements to yield. From the PEP:

[reversed] makes a reverse iterator over sequence objects that support getitem() and len().

So to reverse a string, consume the iterator until it is exhausted. Without using the builtin, it might look something like,

def reverse_string(x: str) -> str:
i = len(x)
while i > 0:
    i -= 1
    yield x[i]
    

Consume the iterator either by looping, eg

for element in (reverse_string('abc')): 
    print(element)

Or calling a constructor like:

cba = list(reverse_string('abc'))

The reverse_string code is almost identical to the PEP with a check removed for simplicity's sake. In practice, use the builtin.

ORIGNAL ANSWER:

Here is a way to reverse a string without utilizing the built in features such as reversed. Negative step values traverse backwards.

def reverse(text):
    rev = ''
    for i in range(len(text), 0, -1):
        rev += text[i-1]
    return rev

Try the reversed builtin:

for c in reversed(string):
     print c

The reversed() call will make an iterator rather than copying the entire string.

PEP 322 details the motivation for reversed() and its advantages over other approaches.