import tkinter as tk def get_primes(): try: n = int(entry.get()) primes = [] for num in range(2, n): for i in range(2, int(num ** 0.5) + 1): if num % i == 0: break else: primes.append(num) result.config(text=primes) except ValueError: result.config(text="Please enter a valid number.") root = tk.Tk() root.title("Prime Numbers") label = tk.Label(root, text="Enter a number:") label.pack(pady=10) entry = tk.Entry(root) entry.pack() button = tk.Button(root, text="Find primes", command=get_primes) button.pack(pady=10) result = tk.Label(root, text="") result.pack() root.mainloop()