I have been trying to create multiple buttons in tkinter library (with numbers as text), using for loop. And i want to print the text of each button every time i click one. Like a calculator. But the problem is that it prints only the last line in the loop.
win=tk.Tk()
def butt(x):
print(x)
for i in range(1,4):
bt=tk.Button(win,text=i,command=lambda: butt(i));bt.pack()
win.mainloop()
One solution of this that i found is to write lambda i=i : ... but i dont understand what this is. Thank you for your time!!