Scope
In this lesson, you'll learn about the scope of variables in Python.
We'll cover the following...
Introduction to scope
The scope of a name is the part of the program in which the name has meaning and can be used. Python’s scope rules are unusual because they follow an “LEGB rule”: Local, Enclosed, Global, Built-in.
To understand this rule, it helps to remember that:
- Variables are defined by being assigned a value.
- Functions/methods may be nested within other functions/ methods.
When dealing with the scope of ...