How do you set a global variable in a function?
Q. I’m trying to change a module variable, but it doesn’t work. Can it be done?
A. Did you do something like this?
x = 1 # make a global module variable def f(): print x # try to print the global ... for j in range(100): if q > 3: x=4
Any variable assigned in a function is local to that function, unless it is specifically declared global. Since a value is bound to x