so I wrote this code for the reverse practice:

reverse_list = []
def reverse(text):
x = -1
n = len(text)
for letters in text:
if x >= -n:
x = x-1
new_word = ''.join(reverse_list)
return new_word

but there is the following error:
Oops, try again. Your function fails on reverse("Python!"). It returns "cba!nohtyP" when it should return "!nohtyP".

And I don't understand where the "abc" comes from! When I run the code on my Idle it works just fine.


the exercise calls the function multiply times for validition, but only the function, not whole script. So place reverse_list inside the function


Thanks a lot!!
Although I still don't get why the "cba" appeared there, unless it is a mistake


its one of the test cases of exercise/validition


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