Global Scope
Let's discuss and understand the global scope.
We'll cover the following
Python includes the global
statement. It is a keyword of Python. The
global
statement declares a variable as being available for the code
block following the statement. While we can create a name before we declare it global
, this is strongly discouraged.
How global scope can be used
Let’s attempt to use
global
to fix our exception from the last example:
Get hands-on with 1200+ tech skills courses.