Using Tkinter in python, trying to make numbered buttons, which use self.do(x) to add the number x to a string variable. The problem with this particular piece of code being in a loop (to save space), is that it will add the LAST number to the string (ie, 9 in this example). This is because it calls the function after this, and uses the latest value of num[i]. Is there any way to correct this?
self.numButton = []
num = []
for i in range(9):
num.append(i + 1)
self.numButton.append(Button(root,text=num[i],command=lambda: self.do(num[i])))