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


Hi friends!


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 = []
            new = "".join(k)
            print new,
            count -=1    
print reverse("Python!")


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


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


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


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


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