7. Reverse, console not working?


#1



So, I know my code works because i called it at the end with a string but it always says
"Oops, try again. Your function fails on reverse("Python!"). It returns "None" when it should return "!nohtyP"." but when i call the function it works fine so why is it not working???


def reverse(text):
    txt = []
    revlen = 0
    for l in str(text):
        txt.append(str(l))
        revlen += 1
    for n in range(revlen):
        print txt[revlen-1],
        revlen -= 1


#2

You are printing the value in reverse to the console rather than returning it.

What print does is provide output to the console. What return does is provide the given value to the location that invoked its function.


#4

I see, so it was a stupid mistake XD