0

I'm trying to make multiple buttons in double for loop. I couldn't find the syntax about this problem.

for i in range(row):
    for j in range(col):
        b = tk.Button(new_root,command = lambda i=i : test1(i,j))
        b.place(x = (j*30), y = (i*30))

I understood that part using i=i to avoid late binding issue for i, but what should I do for j? the other iterator?? thank you so much in advance,

Joey
  • 1

1 Answers1

1

You have to give both variable to lambda function:

lambda i=i, j=j: test1(i,j)