Using tkinter i have a widget for a button - pressing the button runs a function that calls upon num and increases it by 1, prints it and returns it
It calls upon num correctly,will add one to it and then print it however when it is pressed again num has reset suggesting something has gone wrong when returning it
Here is the sample of the code:
import tkinter as tk
num = 0
def increment(num):
num = num + 1
return num
window = tk.Tk()
button1 = tk.Button(
text="Button1",
command= lambda: num == increment(num)
)
button1.pack()
window.mainloop()
No errors occur - any advice / help is appreciated
pressing the button the first time should pass through num as 0 then increase it to 1. Then it should return num as 1 so that when pressed again num is passed though as 1 and then returned as 2. instead num is always passed through as 0