import random

while True:
    number_to_guess = random.randint(1, 100)
    attempts = 0
    max_attempts = 3

    while attempts < max_attempts:
        user_guess = int(input("Enter a number between 1 and 100: "))
        attempts += 1

        if user_guess < number_to_guess:
            print("Your guess is lower than the target number. Try again.")
        elif user_guess > number_to_guess:
            print("Your guess is higher than the target number. Try again.")
        else:
            print("Congratulations! You have successfully guessed the number.")
            break

    if attempts == max_attempts:
        print("Unfortunately, you were not able to guess the number. The number was", number_to_guess)

    play_again = input("Do you want to play again? (yes/no) ")
    if play_again != "yes":
        break


