import random import time # Presets for the game reset_guesses = 0 rounds = 3 user_score = 0 AI_score = 0 round_won = True Game_round = 1 Number_Range = random.randint(1, 1000) Guess = None # Intro print("Hello") time.sleep(0.3) print("Welcome To Take-Away Game") time.sleep(2) print("I am going to pick a number from 1 to 1000 and you have to guess the number.") time.sleep(1) Player_name = input("Please Enter Your Name: ") time.sleep(1) Continuing = input("Do you wish to continue? (y/n): ") # Asking if you want to carry on if Continuing.lower() == "y": time.sleep(1) print("Good Luck, " + Player_name) # This is the function for the game play def play_round(): global Number_Range # Ensure the correct number is used for each round Number_Range = random.randint(1, 1000) # Generate a new number each round attempts = 0 # Track the number of attempts while True: try: guess = int(input("Enter your guess: ")) except ValueError: print("Please enter a valid number.") continue attempts += 1 if guess < Number_Range: print("Too Low!") elif guess > Number_Range: print("Too High!") else: print(f"Correct! The number was {Number_Range}. You guessed it in {attempts} attempts.") return max(10 - (attempts - 1) * 2, 0) # Scoring logic: 10 points max, -2 per extra attempt # Game loop total_rounds = 3 total_score = 0 for round_num in range(1, total_rounds + 1): print(f"\n--- Round {round_num} ---") total_score += play_round() # The End message print(f"Game over! Your total score is {total_score} points.")