I made the following sample to change one of the global variables.
a1 = 0
a2 = 0
a3 = 0
a4 = 0 #and more global variables
def foo():
global a3
if a3 < 1:
a3 = 1
foo()
print a3 #is 1
But I don't want to create a function for each global variable. So, I made the following one.
a1 = 0
a2 = 0
a3 = 0
a4 = 0 #and more global variables
def foo(name):
global name
if name < 1:
name = 1
foo(a3)
print a3 #expect 1
And I got an error message.
SyntaxError: name 'name' is local and global
I don't know how to resolve the issue. Please help.