Reverse - Numbers insteads of strings


Oops, try again. Your function fails on reverse("Python!"). It returns "[[6], [5], [4], [3], [2], [1], [0]]" when it should return "!nohtyP".

Hello Everyone,

Could you help me please? I am trying to understand what is my mistake in this function. Why is it returning numbers while the argument is a string?
Thanks in advance!

def reverse(text):

    while n>0:
    return test    


You say that there's a mistake, that suggests that your code should be for the most part correct.
But I don't see it amounting to reversing a piece of text, it's very far off.
You should probably consider what actions your code needs to carry out. Before you write any code, make sure that you're convinced that carrying those actions out has the desired effect (reversing the text)
You can write those actions as comments, and then later fill in the corresponding code. That way you can check the overall logic by reading the comments, and you can compare each piece of code with the comment that describes what it's supposed to do.

You seem to have gone for the strategy of counting down from the last index to the first. That's fine. But you haven't really done anything else after that, there's a whole lot missing. What else needs to happen?


Thanks for the tip!
I'll try to be patient and find out!


did anybody get it ??


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