Python Local Variables
When we declare variables inside a function, these variables will have a local scope (within the
function). We cannot access them outside the function.
These types of variables are called local variables. For example,
Output
Local Hello
NameError: name 'message' is not defined
Python Global Variables
In Python, a variable declared outside of the function or in global scope is known as a global
variable. This means that a global variable can be accessed inside or outside of the function.
Let's see an example of how a global variable is created in Python.