7. Reverse


Hello! When I put in my code it gives me the error message: "Your function fails on reverse("Python!"). It returns "cba!nohtyP" when it should return "!nohtyP"."

Why has it added an 'abc' to the end of the text?

When I try my own input, for example reverse("Hello"), it works and prints olleH to the console, but still gives me an error message

revers = []
def reverse(text):
    length = len(text) - 1
    for n in text:
       length -= 1
    s = "".join(revers)
    return s


the empty list you store the result in:

revers = []

should be inside the function, since the exercise calls the function multiply times, by placing it outside, there might leftovers from earlier function calls by the exercise


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