I face an issue which is that my first button is using the second button's command. I have faced this logic error multiple times when trying to create buttons programmatically with different functions, is there a way to resolve this or is this a limitation to Tkinter? The gif below illustrates my issue.
import tkinter as tk
root = tk.Tk()
root.geometry("400x400")
def print_when_clicked(message):
print(message)
array = ["hi", "bye"]
for i in array:
tk.Button(root, text=i, command=lambda:print_when_clicked(i)).pack()