Function call and return


When talking about call and return in a function, is it correct to say that is the “print and return statement?” If not, what is it please?
Also, can someone tell me why is that sometimes putting the return statement before the print statement, still talking about function, would not print on the console while, the reverse (putting print before reverse) works?


By default, a function returns None at the end of the function. If we want to return something else at the end of the function, we can use the return keyword.

Given return is the last thing a function does, when a return keyword is reached, the function ends

so putting a print statement after a return, then the print statement is never reached

what do you mean by print and return statement? print prints to stdout (standard output), in most case the terminal (like the terminal window in the lesson the right hand side)

return is literally what it says, it returns/hands you something back:

def example():
    return "hello world"

# store the returned result in x variable
x = example()
print x


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