I try to create buttons in tkinter using a loop.
def bulkbuttons():
    i = 0
    x = 0
    buttons=[]
    while x < 10:
        buttons.append('button' + str(x))
        x+=1
    while i < 10:
        buttons[i]=Button(window,text=str(i), width=12,borderwidth=1, relief='raised', bg='#134f5c', fg='#FFFFFF', command=(lambda: justprint(i)))
        buttons[i].grid(row=i, column=2)
        i += 1
The justprint function prints i.
def justprint(i):
    print(i)
The buttons show the correct numbers. But the justprint function only prints the last number, 10, no matter which button I click.
What did I do wrong? I want to click a button and then use the number of the button as a parameter for some functions.
 
    