LEGB in Python stands for the four scopes that the language uses to look up the value of a variable. It is an acronym for the following:
Local: Refers to the current function or block.
Enclosing: Refers to the local scope of any enclosing functions (from inner to outer).
Global: Refers to the global scope of the module or script.
Built-in: Refers to the built-in names module containing Python's built-in functions.