Answer the question
In order to leave comments, you need to log in
My first time with "local variable 'WITH_GIRL' referenced before assignment" or what is the correct way to declare a variable?
There is a piece of code:
ACTIVE_WINDOW = ''
def on_press(key):
f = open('text.txt', 'a')
if ACTIVE_WINDOW != GetWindowText(GetForegroundWindow()):
ACTIVE_WINDOW = GetWindowText(GetForegroundWindow())
f.write(ACTIVE_WINDOW)
print(ACTIVE_WINDOW)
UnboundLocalError: local variable 'ACTIVE_WINDOW' referenced before assignment
Answer the question
In order to leave comments, you need to log in
Here it is - the result of unsystematic training! Nobody reads textbooks.
active_window = ''
def on_press(key):
global active_window
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question