7/15 "!noh"


When I run this code it only returns "!hon" what happened to the first 3 letters?

def reverse(text):
    text = list(text)
    print text
    result = []
    for letter in text:
        last_letter = text.pop()
    return ''.join(result)


Do this for me and you might understand what you are doing.


a_list = [1, 2, 3, 4, 5]
for index, item in enumerate(a_list):

After you do this you should understand a little better what you are doing to your list as you are working on it. Remember loops only reference the item but if you work directly on the object you can change the behavior of your loop.



Thanks, didn't understand what you meant till I found this http://stackoverflow.com/questions/13939341/why-does-a-for-loop-with-pop-method-or-del-statement-not-iterate-over-all-list


This might Help!

def reverse(text):
x = len(text)
n = ""
while x > 0:
n = n + text[x-1]
x = x - 1
return n