Skip to content

What is NoneType in Python

  • by

The NoneType Object is the type for the None object in Python. This is an object that indicates no value. NoneType is simply the type of the None singleton:

Objects should be checked against nullity before use.

if obj is None:

or

if obj is not None:

NoneType in Python

Simple example code.

obj = None
print(obj)
print(type(obj))

Output:

NoneType in Python

Remove None Elements from the List:

list_in = [1, 3, 'cse', None]
 
lambda_obj = lambda x: (x is not None)
 
list_out = list(filter(lambda_obj, list_in))
 
print(list_out)

Output: [1, 3, ‘cse’]

Do comment if you have any doubts or suggestions on this Python object topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading