title: tkinter button commands with lambda in Python
body: <p>ive tried searching for a solution but couldn't find one that works.  I have a 2d list of tkinter Buttons, and i want to change their Text when it is clicked by the mouse.  I tried doing this:</p>
  
  <pre><code>def create_board(number):
      print(number)
      for i in range (0,number):
          buttonList.append([])
          for j in range(0,number):
              print(i,j)
              buttonList[i].append(Button(root, text = " ", command = lambda: update_binary_text(i,j)))
              buttonList[i][j].pack()
  </code></pre>
  
  <p>Then when it is clicked it calls this function:</p>
  
  <pre><code>def update_binary_text(first,second):
      print(first,second)
      buttonList[first][second]["text"] = "1"
  </code></pre>
  
  <p>When i click a button, it simply does nothing, i had the program display the indexes of the button that was clicked, and they ALL show 4, 4 (this is when the variable number=5)  Is there an solution to this?<br>
  this is my first python attempt for a class.  </p>
  
  <p>Thanks</p>