The "Reverse" problem from the course


#1



https://www.codecademy.com/courses/python-intermediate-en-rCQKw/1/1?curriculum_id=4f89dab3d788890003000096#

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)


#2

>>> reverse('abc')
'cba'
>>> reverse('abc')
'cbacba'
>>>

#3

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


#4

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??


#5

never mind... got it


#6

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