Understand the difference between local scope and global scope Here are some things to keep in mind when dealing with each variable.
The local scope refers to the inside of the defined function, and the variables available in it are called local variables.
def sample():
a =1 * Local scope
The global scope points to the target python file and can be referenced from any function.
b =2 * Global scope
def sample():
a = 2
Global scope can be handled from within local scope
local = 100
def global():
a = 100
print(local + a)