Error with print and return commands - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Error with print and return commands (/thread-23749.html) |
Error with print and return commands - TheDark_Knight - Jan-15-2020 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. RE: Error with print and return commands - stullis - Jan-15-2020 The return keyword terminates the function. You'll need the print() call prior to return. RE: Error with print and return commands - TheDark_Knight - Jan-15-2020 (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? |