I am trying to make a buttons that prints values what i assing to them. In my mind all buttons should print same values on their text value. Instead they all print "4". What is the wright way to solve this?
from tkinter import *
root = Tk()
def printFunc(text):
print(text)
list=[0,1,2,3,4]
for i in list:
w = Button(root, text=list[i],command=lambda: printFunc(list[i])).pack()
root.mainloop()