
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to return none from Python function?
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.
Example
One sample code is given below that returns None.
def lyrics(): pass a = lyrics() print a
Output
None
- Related Questions & Answers
- How to return void from Python function?
- How to return a json object from a Python function?
- How to return an object from a function in Python?
- How to return table from MySQL function?
- How can we return a dictionary from a Python function?
- How can we return a tuple from a Python function?
- How can we return a list from a Python function?
- How to return a JSON object from a Python function in Tkinter?
- How can a Python function return a function?
- How to return variable value from jQuery event function?
- How to return a value from a JavaScript function?
- How to return a string from a JavaScript function?
- How to return an object from a JavaScript function?
- How to return local array from a C++ function?
- How to return an array from a function in C++?
Advertisements