def select_difficulty(): print("Select Difficulty Level:") print("1. Easy (1 to 10)") print("2. Medium (2 to 12)") print("3. Hard (5 to 20)") while True: choice = input("Enter choice (1-3): ").strip() if choice == "1": return (1, 10) elif choice == "2": return (2, 12) elif choice == "3": return (5, 20) else: print("Invalid selection. Please enter 1, 2, or 3.") def get_positive_integer(prompt): while True: try: value = int(input(prompt)) if value > 0: return value print("Please enter a number greater than 0.") except ValueError: print("Invalid input. Please enter a whole number.") def get_user_answer(prompt): while True: try: return int(input(prompt)) except ValueError: print("Invalid input! Please enter a valid integer.")