Python Forum

Full Version: Error with print and return commands
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Hello guys, I'm new to Python, just tried running a simple code but am facing an error. Here's how my code looks like-

def f(x):
    return x+10
    print "wOw"
And here's the output:
f(73)
output--> 83

Why does it not print what I have written after the return command, in my code?

Would appreciate suggestions. This is my first message , sorry for mistakes if any, and feel free to point them out. Thanks.
The return keyword terminates the function. You'll need the print() call prior to return.
(Jan-15-2020, 04:06 PM)stullis Wrote: [ -> ]The return keyword terminates the function. You'll need the print() call prior to return.

Thanks for the response. This helped me learn a new thing.
However, does it mean that it's never possible to have an output consisting of a number + text, using the return command? For e.g. 10 chocolates?