I need to define a variable within a function and use it in a function that is within the original function. For example,
def go_to_next_function():
globvar = 0
def add_one_to_globvar():
global globvar
for i in range(10):
globvar += 1
print(globvar)
add_one_to_globvar()
go_to_next_function()
Now I know if globvar
is defined outside all of the functions then it would work, but I want it to be defined inside the go_to_next_function()
function. Any ideas? Thanks.