I keep getting "Oops, try again. Your function fails on reverse("Python!"). It returns "!" when it should return "!nohtyP". I don't understand why the while statement breaks after returning the first item that is stored in list x.

Replace this line with your code. 
def reverse(text):
    lists = []
    for key in text:
    a = len(text)
    while a > 0:
        a -= 1
        x = []
        return "".join(x)


Initialize your empty list outside of the loop.


Thanks You!! It works now.


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