My global variable count=0
is being changed in the function (method) below:
def Counter(counter,boolean=False)->int:
if boolean:
counter+=1
else:
counter=0
return counter
and other functions uses Counter
function:
def func1():
global count
count=Counter(count,True)
print("func1:",count)
def func2():
global count
count=Counter(count,True)
print("func2:",count)
When run these functions one more time like for
loop
for _ in range(3):
func1()
func2()
the output is:
func1:1
func2:2
func1:3
func2:4
func1:5
func2:6
But output must be like this:
func1:1
func2:1
func1:2
func2:2
func1:3
func2:3
I researched different ways but could not find an answer. How can I do that?