for x in range(NumberofStats):
d = {}
d["Stat{0}".format(x)] = tkinter.Button(root,text=Stats[x][0],width = Width,command = lambda: PickStat(x))
print(x)
d["Stat{0}".format(x)].place(relx = 0.01 + (Room*CounterStats),rely = 0.37 + CounterStats2 * 0.05)
CounterStats += 1
if CounterStats > 2:
CounterStats = 0
CounterStats2 += 1
Whenever I use a button it referes to the variable and but I want it do refere to what the variable was at the time it was created. So if Stat1 is pressed it should call PickStat(1) and not PickStat(x)
Any help is welcome