7. reverse



Oops, try again. Your function fails on reverse("Python!"). It returns "None" when it should return "!nohtyP".

This seems to work perfectly fine when I execute the code in PyCharm. For whatever reason, the lesson doesn't seem to like the submission. Any thoughts? I've read other posts and gotten other solutions to work, but this seemed more intuitive to me. Thanks in advance for any feedback.

def reverse(text):
    backwards = []
    for letter in text:
    end = ""
    for item in backwards:
        end += item
    print end


your function prints the reversed string, it doesn't return the reversed string


Sorry for wasting your time... Little things like that don't register sometimes after working through lots of these problems.

Thanks for your help!


no problem. Exactly, so then you can use a little help :slight_smile:


Can someone explain to me piece by piece what is happening? I don't feel prepared at all to do this.


well, isn't that part of the challenge to maximize the learning effect?

we could use range() for this, given range also allows to loop from right to left, if we do this we can append to list/string, causing the string to reverse


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