Local and Global Variables in Python
- A local variable is a variable that only be used inside of its function.
- On the other hand, a Global variable is a variable that can be used outside of its function and used by all functions.
x = "im Global" def mafun(): x = "im local" print("My type is " + x) mafun() print("My type is " + x)
My type is im local My type is im Global