7. reverse (I've almost got it, but there's a problem)


#1


Hi friends!


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

I'm stuck at exercise.

I think I've almost made it, but instead of printing or returning !nohtyP it returns ! n o h t y P. I know my code may be wrong.


I would like to print !nohtyP without those spaces. I need your help, please.


def reverse(x):
    count = len(x)-1
    for letter in range(-1,count):
        if count >= 0:
            k = []
            k.append((x[count]))
            new = "".join(k)
            print new,
            count -=1    
print reverse("Python!")


#2

Your function doesn't return anything and should not print anything.


#3

hello,
Firstly your function doesn't return anything so you have to replace print by return.
and then if the code work but you couldn't pass the test add those lines at the end of your code.

del inverser
NameError = Exception = None

In this way you trick the tester. Use it only if your code is working

Have a nice day


#4

Thank you both, my code is wrong. I tried to do it differently, now I need to fix it.


#5

There's no reason to try to crash the submission test when it's behaving like it should


#10

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