0
B=False

def func1():
    def func2():
        global B
        if B == True:
            print("True")
            B=False
        else:
            print("False")

    B=True
    func2()
func1()

This is an example of the problem I am having, when I set a variable as a Boolean within a function, the Boolean seems to change when brought to another function, e.g. here the Boolean B is set to True in func1() but in func2(), where B should still be True, the output of the code is False, signifying the Boolean has become False.

eshirvana
  • 23,227
  • 3
  • 22
  • 38
Lydia
  • 1

0 Answers0