Return Values and Scope
Understand return statements and variable scope (local vs global).
Introduction
Understanding return statements and variable scope is fundamental to writing predictable, bug-free Python functions.
The return Statement
return expr exits the function and sends expr back to the caller. return without a value sends None.
def double(x):
return x * 2
print(double(5))All lessons in this course
- Defining and Calling Functions
- Default and Keyword Arguments
- args and kwargs
- Return Values and Scope