The Python return keyword allows you to define the return value of a function (e.g., return X). If you don’t explicitly set a return value or you omit the return statement, Python will implicitly return the following default value: None.

There are three cases of what a function can return:
β₯οΈ Info: Are you AI curious but you still have to create real impactful projects? Join our official AI builder club on Skool (only $5): SHIP! - One Project Per Month
- Case 1: The function has a
returnstatement that returns an explicit value. - Case 2: The function has a
returnstatement that returns explicitly nothing. It returnsNone. - Case 3: The function does not have a
returnstatement. The function in that case implicitly returnsNone.
Let’s have an example of all three cases next!
Case 1: The function has a return statement that returns an explicit value.
def f1():
return 42
print(f1())
# 42Case 2: The function has a return statement that returns explicitly nothing. It returns None.
def f2():
return
print(f2())
# NoneCase 3: The function does not have a return statement. The function in that case implicitly returns None.
def f3():
pass
print(f3())
# None
Feel free to check out our Python cheat sheets to learn about all the Python basics and keywords and tricks: