Help me on the codes for Reverse exercise


#1



Hello

I have been struggling with my code for Reverse exercise. Can anyone help me please?

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

Here is my code:

def reverse(x):
    revd = []
    x = str(x)
    for n in x:
        revd.insert(0,str(n))
    print "".join(revd)

reverse("Python!")

When I hit the "Save & Submit Code" button, the terminal returns "!nohtyP", which looks perfect.

However, it keeps showing this error message:
"Oops, try again. Your function fails on reverse("Python!"). It returns "None" when it should return "!nohtyP"."


Can anyone please help me figure out what went wrong with my code?

Thanks


#2

from the instructions:

Define a function called reverse that takes a string text and returns that string in reverse

there is a important word in this sentence: returns, this should ring a bell, that you might need to use a return keyword


#3

Hello stetim94

Thanks a lot! The error is solved when I replace print with return.

Cheers


#4