Reverse - stuck


It should return !nohtyP but I get this weird error message: Your function fails on reverse("Python!"). It returns "cba!nohtyP" when it should return "!nohtyP". While testing the function I created a str variable called "test" and assigned abc and removed afterwards.

I checked whether the list is empty before the function is called so when printed it returns as [] so I believe it is empty

result = []
def reverse(text):
    for n in range(1,len(text)+1):
    return ''.join(result)


the exercise calls the function multiply times for different string to see it works correctly.

so place result = [] inside the function


so in my case the the loop is not able to append to results since it is a global list rather than a locak one?


no, the exercise calls the function multiply times to validate it works correctly.

not the whole script, so the list will maintain data from earlier function calls


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