I need help with if. This code just when you click a button it +1 to a counter and the problem is I need something when the counter reaches 10 5 points substract and something will happned and I dont know how to do it I tried this but nothing
solved it thanks people for listening
here is the right code
if counter == "5": // does not work //something if counter == 5: // does not work //something
from tkinter import * root = Tk() root.geometry("200x200") root.title("My Clicker Game") global counter counter = 0 def nClick(): global counter counter += 1 print("hello") mLabel.config(text = counter) mButton1 = Button(text = "Mine Gold", command = nClick, fg = "darkgreen", bg = "white") mButton1.pack() mButton2 = Button(text = "Goodbye", command = root.destroy, fg = "darkblue", bg = "white") mButton2.pack() mLabel = Label() mLabel.pack() root.mainloop()
solved it thanks people for listening
here is the right code
from tkinter import * abc = 1 root = Tk() root.geometry("200x200") root.title("My Clicker Game") global counter counter = 0 def nClick(): global counter counter += abc ab = counter if ab == 5: print("hello") mLabel.config(text = counter) mButton1 = Button(text = "Mine Gold", command = nClick, fg = "darkgreen", bg = "white") mButton1.pack() mButton2 = Button(text = "Goodbye", command = root.destroy, fg = "darkblue", bg = "white") mButton2.pack() mLabel = Label() mLabel.pack() root.mainloop()The problem was I didnt reference the updated counter