In Python Tkinter, I am trying to make a button which returns its text when clicked. I am making multiple buttons so a for loop will be used.
This is so far what I have come up with:
lst = ["a", "b", "c", "d"]
for i in range(len(lst)):
Button(window, text = lst[i], command = lambda : print(lst[i]))
The problem with this code is, when I click on the buttons, it will only print the last element from lst.
Please can someone help me out?