So I have created 5 x 5 buttons using for-loop:
for i in range(5):
for j in range(5):
    gameButton = Button(boardFrame, bg="khaki1", width=10, height=5, command=colorTheButton)
    gameButton.grid(row=i, column=j, sticky=E)
and I have a function called changeColor():
def colorTheButton():
    global colorCounter, boardColor
    row = gameButton.grid_info()['row']
    column = gameButton.grid_info()['column']
    if colorCounter % 2 == 0:
        boardColor = "black"
    else:
        boardColor = "white"
    colorCounter += 1
    button = button(boardFrame, bg=boardColor, width=10, height=5)
    button.grid(row=row, column=column)
Now the problem is, every time I click any button it'll not change the color of the clicked button instead, it'll change the color of the last created button. What should I do to change the clicked button instead of the last one?
 
     
    