This is an attempt to make a number increase when a button is clicked.
def something():
CP = 0
counter = StringVar()
counter.set("0")
def click():
global CP
global counter
CP = CP + 1
counter.set(str(CP))
label5=Label(window, textvariable=counter, font=("Georgia", 16), fg="blue")
button5=Button(window, text='Make a Clip', command=click)
label5.pack()
button5.pack()
There is a name error on line 6 of this section.
Traceback (most recent call last):
File "D:\Program Files\Python\Python36\lib\tkinter\__init__.py", line 1699, in __call__
return self.func(*args)
File "D:\Program Files\Python\Python36\Paperclips.py", line 14, in click
CP = CP + 1
NameError: name 'CP' is not defined
What is wrong with the code?