Student did something like this in my Python class today. Can you spot the mistake? Took me a while.
Output when you run is "hello" then "NameError: name 'button' is not defined". No window appears.
import tkinter as tk
from tkinter import ttk
def do_when_clicked(): # When the button is clicked:
print("hello")
button.destroy()
gui = tk.Tk()
button = ttk.Button(gui, text="Click me", command=do_when_clicked())
button.pack()
gui.mainloop()