How to use global variable in python?
![](https://pythonpoint.net/wp-content/uploads/2020/11/Yellow-Fishing-Boat-Blog-Banner-1024x576.jpg)
Variables declared outside a function or in global space are called global variables. These variables can be accessed by any function in the python program.
e.g.,
def demo(): print(a) a = "Python" demo()
![](https://pythonpoint.net/wp-content/uploads/2020/11/Screenshot-871-1024x418.png)
e.g.,
x= 5 y = 20 def multiply(): z = x * y print(z) multiply()
![](https://pythonpoint.net/wp-content/uploads/2020/11/Screenshot-873-1024x428.png)
This is all about global variables in python.
Subscribe
Login
Please login to comment
0 Discussion