I'm a beginner in python, and was trying to create a basic GUI calculator using Tkinter module. My code gives me an error UnboundLocalError: local variable 'display' referenced before assignment even when I've assigned the value to the variable in the beginning of the code. Here is my code, any help will be appriciated.
display = ""
flag = 0
def set():
display = display + str(a)
if flag == 0:
calc1 = float(display)
elif flag == 1:
calc2 = float(display[len(str(calc1)) - 1:END])
label.config(text = display)
print (calc1)
print (calc2)
print (display)
def set0():
a=0
set()
# similar functions for values 1-9
set0()