I want to something like this:
list = [0,1,2,3,4]
for x in range(len(list)):
    hi = tk.Button(command = lambda: function)
def function():
    print(list[x])
The problem is x is always 5 so it always prints 4, I want it to print the corresponding value. Is there any way to do this?
 
    