Tsallaka zuwa abun ciki
Justice Tech School

None

None represents "no value". Functions that do not return anything give None. Compare with None using is, not ==. It is often used as a default that means "not provided".

Example
result = None
print(result)
print(result is None)

def nothing():
    pass

print(nothing())

def greet(name=None):
    if name is None:
        return "Hello, stranger"
    return "Hello, " + name

print(greet())
print(greet("Ada"))

Result

None
True
None
Hello, stranger
Hello, Ada

Exercise

Check for None correctly.

if value  None:
    print("empty")

Quiz Test

What does a function with no return give back?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.