The idea of this code is, the user presses the first button and enters what they want, then they press the second button and it prints it out. Can someone please tell me why my return statement is not working? It says that 'variable' is not defined. Thanks in advance for taking the time to read my question.
from tkinter import* def fun(): variable = input('Enter Here:') return variable def fun_2(): print(variable) window = Tk() button = Button(text = 'Button', command = fun ) button2 = Button(text = 'Button2', command = fun_2 ) button.pack() button2.pack() window.mainloop()