I have 2 Python files:
functions.py
global counter
counter = 0
def printC():
print(counter)
def increaseC():
counter += 1
and a main.py
from functions import printC
from functions import increaseC
printC()
increaseC()
The first function prints the 0 with no problem but then i get that error message:
counter += 1
UnboundLocalError: local variable 'counter' referenced before assignment
My question is: How can i increase that global variable that way than i can print the same way like this:
from functions import printC
from functions import increaseC
printC()
increaseC()
printC()
To get the second print with 1 value?