Function Scope
This lesson will highlight some important things to know about a function's scope.
We'll cover the following
The scope of a function means the extent to which the variables and other data items made inside the function are accessible in code.
In Python, the function scope is the function’s body.
Whenever a function runs, the program moves into the function scope. It moves back to the outer scope once the function has ended.
Data Lifecycle #
In Python, data created inside the function cannot be used from the outside unless it is being returned from the function.
Variables in a function are isolated from the rest of the program. When the function ends, they are released from memory and cannot be recovered.
The following code will never work: