A global variable in Python is one that is assigned at the top level of a module, i.e., outside of any function or class definition. Such variables become part of the module's global namespace and can be accessed (and, using the global statement, modified) from within functions defined in that module. This is distinct from local variables, which are defined inside a function and exist only within that function's local scope.
Community Discussion