BoardValue = ["1","2","3","4","5","6","7","8","9","0"]
for i, b in enumerate(BoardValue):
row = int(i/3)+1
col = i%3
btn = Button(root, text=b,padx=40, pady=20, command= lambda: button_click(i))
btn.grid(row=row, column=col)
my code is as above
the command function is
def button_click(number):
e.delete(0, END)
e.insert(0, number)
however, the error is the command argument. when I press the button, I only get 9 which is not the corresponding output from the button.
i would like to ask how to resolve it while keeping the for loop.