7 - Reverse


Your function fails on reverse("Python!"). It returns "!" when it should return "!nohtyP".

Is it possible to make this work?

def reverse(text):
    length = 0
    for symbols in text:
        length += 1
    length -= 1
    while length != -1:
        return text[length]
        length -= 1


Sure? But is that really what you meant to ask?
Make your questions really specific, pin down what information you need. (And don't be surprised if you find that after establishing the problem you're able to answer yourself)


You are on the right track but dont return it just yet

Create an empty string variable and add text[length] to it.

Then, after the while loop , at the end of the function return that string variable you created.


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