Get your
own Python
server
Change Orientation
Ctrl+Alt+O
Change Theme
Ctrl+Alt+D
Change Language
Go to Spaces
Ctrl+Alt+P
import tkinter as tk import random window = tk.Tk() window.title("Guess the Number") window.geometry("300x200") secret = random.randint(1, 100) tries = 0 def check(): global tries try: guess = int(entry.get()) except ValueError: result.config(text="Not a number!") return tries += 1 if guess < secret: msg = "Too low!" elif guess > secret: msg = "Too high!" else: msg = f"Correct! Tries: {tries}" result.config(text=msg) question = "Guess a number from 1 to 100" info = tk.Label(window, text=question) info.pack(pady=10) entry = tk.Entry(window) entry.pack() button = tk.Button(window, text="Guess", command=check) button.pack(pady=10) result = tk.Label(window) result.pack() window.mainloop()