Answer
Scope is the textual region where a name can be referenced directly. • Python resolves names through local, enclosing function, global, and built-in scopes. • global and nonlocal change where assignment binds a name. • Class scopes have special lookup behavior and do not form ordinary enclosing function scopes.
💡 Simple Example
value = 'global'
def outer():
value = 'enclosing'
def inner():
print(value)
inner()
outer()
Output
enclosing
⚡ Quick Revision
Python name lookup commonly follows local, enclosing, global, and built-in scopes.