NoneEasy Examples

Represents the absence of a value; Python's null equivalent

None as a null value

Using None to represent absence of a value.

python
x = None
print(x)
print(type(x))

# Always use 'is' to check for None
print(x is None)
print(x == None)  # works but 'is' is preferred
Expected Output
None
<class 'NoneType'>
True
True

None is Python's null. Use 'is None' not '== None' because 'is' checks identity, which is both faster and safer.

None as a default return

Functions return None if no return statement is given.

python
def greet(name):
    print(f"Hello, {name}!")

result = greet("Alice")
print(f"Return value: {result}")
print(f"Is None: {result is None}")
Expected Output
Hello, Alice!
Return value: None
Is None: True

Functions without a return statement implicitly return None.

Want to try these examples interactively?

Open Easy Playground