import random

def play_game():
    # Generate a random number between 1 and 100
    secret_number = random.randint(1, 100)
    attempts = 5

    print("Welcome to the Number Guessing Game!")
    print("I'm thinking of a number between 1 and 100.")

    while attempts > 0:
        print("You have", attempts, "attempts remaining.")
        guess = int(input("Take a guess: "))

        if guess < secret_number:
            print("Too low!")
        elif guess > secret_number:
            print("Too high!")
        else:
            print("Congratulations! You guessed the number!")
            break

        attempts -= 1
        print()
        
    if attempts == 0:
        print("Game over! You ran out of attempts.")
        print("The secret number was:", secret_number)

    play_again = input("Do you want to play again? (yes/no): ")
    if play_again.lower() == "yes":
        print()
        play_game()
    else:
        print("Thank you for playing the Number Guessing Game!")

play_game()

    