0
How to add global variables?
2 Respostas
0
Simply when you define a variable inside a function you can't acess to it outside the function and if you define a variable outside the function thats global variable and you access to it inside the function , example:
def foo():
x='local'
Print(x)
This gives you error becuase x is local and tried to access to it outside the function
And :
x="global"
def foo():
print(x)
It prints x beacause x is global as you called it
0
def f():
global x = 123
print(x) # it's print 123