[Solved] Using two return statements in a function (Python 2.7)


The function only prints out “Hello “.

Then it returns, and its return value is “World.”. Returning means the function is finished and the interpreter continues wherever it was before the function was called, so whatever comes after the return is irrelevant.

You called it as print doPrint(), which calls the function and prints whatever the return value is (we know it turned out to be “World.”).

So the end result is that “Hello World.” was printed.

solved Using two return statements in a function (Python 2.7)