Getting passed, but no output?


#1



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


This is getting approved, but I have no output. It's not printing what I'm intending it to print, but I'm still getting passed. For example, I'm just getting "None" in the output viewer.


def reverse(text):
    new = ""
    for char in range(len(text)-1,-1,-1):
        new = new + text[char]
    return new
    print new   
        
reverse("hello")


#2

to print what a function returns, you should add print in front of the function call


#3

Thank you for your response. Is there a way to put print inside the function, though? So I can just call the function without print?


#4

yea of course, but you have to realize that a function ends the moment a return keyword is reached

so the print statement you currently placed inside your function won't be reached, given return will end the function


#5

Ah, I see. I just reversed the order of return and print and it worked. Thanks!


#6

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