This is a keyword in Python. This instruction has two different variants. Let’s consider them separately.
“return” without an expression
When it used inside a function, it causes the immediate termination of the function’s execution, and an instant return (hence the name) to the point of invocation.
If a function is not intended to produce a result, using the “return” instruction is not obligatory. It will be executed implicitly at the end of the function.
Let’s consider the below example.
Output will be
And the next example is
Output will be
“return” with an expression
The second “return” variant is extended with an expression.
function () :
return expression
So, here consider the below example.
Result is
Sometimes that function not return the value and ignore it.
Output is
No comments:
Post a Comment