+4 votes
in Programming Languages by (18.7k points)
If no return statement is specified in a function, what value will it return?

1 Answer

0 votes
by (32.8k points)

A function returns the None object by default if the "return" statement is not mentioned in the function. A return statement with no expression in it also returns None.

Here are examples:

Without return statement

>>> def fnc(a,b):
...     c=a+b
...
>>> print(fnc(2,3))
None

Return without any expression

>>> def fnc(a,b):
...     c=a+b
...     return
...
>>> print(fnc(2,3))
None

...