I was creating a sort of button-based paint with tkinter, so I wanted to give every button a command to paint itself.
for i in range(xc*yc): grid.append(Button(wn,text=" ",bg="white",padx=5,pady=5)) grid[-1].config(command = paint(i)) <--???? grid[-1].place(x= (i%xc) * 30 +60, y = (math.floor(i/xc) * 30)+30)
The problem is that every button recieves the command "paint(i)" with the final value of i, so everytime it paints the last button