Reverse - Not sure why this doesn't work


#1

In my head, this should work. But the output I'm getting is:

"['!', 'o', 't', 'P', 'b', 'a', 'c', 'y', 'h', 'n']"

I don't understand where a, b, and c are coming from. It also seems to be appending my list in an extremely weird order. It prints in this order even with characters.reverse() removed.

I'm also getting the error on the lesson of "Your function fails on reverse("Python!"). It returns "None" when it should return "!nohtyP"."

def reverse(text):
    for letters in text:
        characters = []
        characters.append(letters)
        characters.reverse()
    
print characters

#2

For starters, you don't store the reversed string anywhere.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.