Do Python Functions Need a Return

Do Python Functions Need a Return

A Python function will always have a return value. There is no notion of procedure or routine in Python. So, if you don’t explicitly use a return value in a return statement, or if you totally omit the return statement, then Python will implicitly return a default value for you.

Is return necessary in Python functions?

No, it is not necessary. The function returns after the last line. There is no difference between a simple return and no return .

Do you need return at the end of a Python function?

A return statement effectively ends a function; that is, when the Python interpreter executes a function’s instructions and reaches the return , it will exit the function at that point.

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.