I want to make a GUI by using Tkinter, the program will analyze some files and then automatically list a list of items with button that when I click to it, it will run some specific function. But now every script I made will end up only run the function of the last item be listed. For example, my aim for the script below is the program will list button with number 0 to 14, when I click to it, it will print on console the number on that button. But by somehow it always print number 14, which the last button be listed.
from tkinter import *
r = []
for x in range(0,15):
r.append(x)
def show(x = int()):
print(r[x])
root = Tk()
for x in range(0,15):
Button(root, text = str(x), command = lambda:show(x)).pack()
root.mainloop()