try to understand how to assign value to a variable from nested function. but it does not work. is it because when I use a = b, it consider a is local variable for nested function? then how can I assign value to the a variable from func?
def func():
a = 0
def nested(b):
global a
a = b
nested(3)
return a
print(func())
nonlocalinstead ofglobal, that being said I agree with @ParitoshSingh that you should return not assign the value unless you are working with something like a decorator.