I have the following simplified version of my code:
import time
def inner(condition, callback):
while condition:
print('test')
time.sleep(1)
callback()
def outer():
condition = True
def callback():
nonlocal condition
condition = False
inner(condition, callback)
outer()
Currently, the above code continues to print, even though i change the condition variable to false in the callback function. I want the condition to change to False, and the while loop to exit.
How come the variable change is not detected in the inner func?