Reverse help


I got the error message: Your function fails on reverse("Python!"). It returns "['P']" when it should return "!nohtyP".

I expected the program to take a string and place each character into a list, then iterate backwards through the list, printing each character as it went.

def reverse(x):
    char = []
    for c in x:
    for i in char[len(char):0:-1]:
        print i
    print char[0]


you need to return the reversed string

to get from list to string at the end, you can use .join()


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