import random

LOWER_BOUND = 1
UPPER_BOUND = 100
MAX_ATTEMPTS = 6


def main():
    print("Welcome to the Number Guessing Game!")

    # Generate a random number between LOWER_BOUND and UPPER_BOUND
    secret_number = random.randint(LOWER_BOUND, UPPER_BOUND)
    attempts_left = MAX_ATTEMPTS

    while True:
        try:
            user_guess = int(input(f"Guess a number between {LOWER_BOUND} and {UPPER_BOUND}: "))

            if user_guess == secret_number:
                print("\nCongratulations! You guessed the right number.")
                break

            elif user_guess < secret_number:
                print("\nYour guess is too low.")

            else:
                print("\nYour guess is too high.")

            attempts_left -= 1

            if attempts_left <= 0:
                print("\nSorry, but you have run out of attempts.\nThe correct number was:", secret_number)
                break

        except ValueError:
            print("\nPlease enter a valid integer.\n")

    play_again = input("Do you want to play again? (y/n): ")
    if play_again.lower().startswith('y'):
        main()
    else:
        print("Thank you for playing!\nGoodbye!")


if __name__ == "__main__":
    main()