September 17, 2026
Why Does My Function Return None When I Expected a Value?
This is one of the most common surprises for anyone new to writing functions: the function clearly does some work, but whatever calls it gets None back instead of a real result.
return is not automatic
Python doesn't guess what you want handed back. Without an explicit return statement, every function returns None by default — even one that computed a value and stored it in a local variable, like total above. Assigning to a variable inside a function is not the same thing as returning it.
def add(a, b):
total = a + b
return total
result = add(3, 4)
print(result)7
Adding return total sends the value back to wherever add() was called, so result actually holds 7 instead of None.
A common variant of this same bug: using print() inside a function instead of return. print() displays a value on the screen, but it doesn't make that value usable anywhere else in your program — only return does that.
See the Functions lesson in our free Python course for a full walkthrough of def, parameters, and return.