title: Python TKinter: how to delete multiple widgets by the same name created in a for loop?
body: <p>I have been trying to make a board game in Python but I was wondering how to delete multiple buttons in a for loop, as all of the buttons are called <code>btn</code> and were created in  a for loop. Currently, all it does is print each number when you click on it but I would like the bottom button to delete all of the numbered buttons. Currently, it only deletes button number 63, no matter how many times I press it. Does anyone know how I can delete all of them or use a workaround by deleting the frame or something? Here is the code which I have so far and have described.</p>
  
  <pre><code>from tkinter import *
  from time import *
  def remove():
      for x in range(0,64):
          btn.destroy()
  def main():
      root = Tk()
      root.title("8x8 grid")
      Button(command = remove,text = "Remove all").grid(row = 8,column = 3,columnspan = 2)
      for pos in range(0,64):
          global btn
          btn = Button(command = lambda pos = pos: print(pos),width = 5,height = 2,relief = RIDGE,text = pos)
          btn.grid(row = pos // 8,column = pos % 8)
      root.mainloop()
  main()
  </code></pre>
  
  <p>Thanks everyone!
  (Sorry if this question has already been asked - I have not found any others that have asked the same question)</p>