Python Variable Scope: Local, Global, Nonlocal and LEGB
Scope decides where a Python variable can be seen: a name created inside a function is local, and a name at the top of a file is global. Python looks names up in Local, Enclosing, Global, then Built-in scope, the LEGB rule. These examples ran on Python 3.12.5, and the screenshots come straight from the … Read more >>









