Skip to main content

One doc tagged with "legb"

View all tags

Scope: Local, Enclosing, Global, and Built-in (LEGB Rule)

We've been working with variables and functions, but we haven't yet discussed a crucial concept: scope. Scope determines the visibility and accessibility of a variable. In other words, it answers the question, "Where in my program can I access this variable?" Understanding scope is essential for writing bug-free code and avoiding common errors where variables seem to "disappear" or have unexpected values.