You've been bitten by the 'global feature' of Python. The following code will demonstrate one way to fix your problem.
def myFunction(): p = True return def myFunction2(): global p p = True return def myFunction3(p): p = True return p p = False myFunction() print("p after myFunction = {}.".format(p)) p = False myFunction2() print("p after myFunction2 = {}.".format(p)) p = False p = myFunction3(p) print("p after myFunction3 = {}.".format(p))
Output:p after myFunction = False.
p after myFunction2 = True.
p after myFunction3 = True.
Lewis
To paraphrase: 'Throw out your dead' code. https://www.youtube.com/watch?v=grbSQ6O6kbs Forward to 1:00