title: Python Tkinter button callback
body: <p>I am trying to print out the button number when i click each buttons that are created by for loop. The following is what i have tried.   </p>
  
  <pre><code>import Tkinter as tk
  root=tk.Tk()
  
  def myfunction(a):
          print a
  
  for i in range(10):
      tk.Button(root,text='button'+str(i),command=lambda:myfunction(i)).place(x=10,y=(10+(25*i)))
  root.mainloop()
  </code></pre>
  
  <p>But instead of printing out each button number, it actually giving me the last button number everytime. Is there anything i can do so that when i click button 1, it will print 1,2 for 2 ,and so on? </p>