The "Reverse" problem from the course


system says that my code returns "cba !nohtyP" when it shoud...

I decided to turn one of my laptops into an Ubuntu box. So, In an effort to do this python class, I've been writing each of the exercises on that laptop as well (using SPE). Since they've all worked as expected, it's served as just extra practice using SPE. Then came this exercise. My Ubuntu laptop works just fine. I get "!nohtyP" as a return, but the system returns as above." So, I'm asking for a bit of understanding.

Thanks in advance,

new_text = []

def reverse(text):
    for i in range(len(text), 0, -1):
        new_text.append(eval(repr(text[i - 1])))
    return ''.join(new_text)


>>> reverse('abc')
>>> reverse('abc')


So, simply putting the initialization inside the function definition, I now get:


Sorry, wrong button... I get

It returns "!nohtyP " when it should return "!nohtyP".

I did, indeed, get rid of the cba - stupid me - but still not passing, though now it does return, what I believed it should??


never mind... got it


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