7 - Reverse


#1



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


#2

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)


#3

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.


#4

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