So I keep getting the error:
UnboundLocalError: local variable 'old_result' referenced before assignment
and I dont exactly know why.
I usually code in javascript, so im new to python but as much as ive figured its because i declare old_result in the function again, but I would like to make it global and just change its value in the function. Anyway I can fix this?
from PIL import Image, ImageGrab
import pytesseract
import threading
import winsound
old_result = 100
def ocrit():
    threading.Timer(5.0, ocrit).start()
    img = ImageGrab.grab(bbox=(110,70,250,200))
    result = pytesseract.image_to_string(img, 
    lang='eng')
    print(result)
    new_result = int(result)
    if new_result < old_result:
        print("play da music")
        old_result = new_result
ocrit()
 
     
    