How to return none from Python function?

PythonServer Side ProgrammingProgramming

Functions without a return statement known as void functions return None from the function. To return a value other than None, you need to use a return statement in the functions; and such functions are called fruitful functions.

Values like None, True and False are not strings: they are special values and keywords in python and are part of the syntax.

If we get to the end of any function and we have not explicitly executed any return statement, Python automatically returns the value None.

Some functions exists purely to perform actions rather than to calculate and return a result. Such functions are called procedures.


One sample code is given below that returns None.

def lyrics(): pass
a = lyrics()
print a


Published on 07-Dec-2017 12:15:11