How to return void from Python function?

PythonServer Side ProgrammingProgramming

Since Python is dynamic-typed and you don't specify a return type when defining a function, then you can return anything with any type, that includes None which is the default return value (when you don't return anything, the function actually returns None at the bottom of function)

Functions like this are called void, and they return None, Python's special object for "nothing".

Also a simple return is equivalent to return None if you want to do it in the middle of function.

Published on 07-Dec-2017 12:43:20