import random

number = random.randint(1, 8)

print("I have selected a number between 1 and 8.")
print("You have 3 attempts to guess it correctly.")


guess = int(input("1) Enter your guess: "))
if guess < number:
    print("Too low")
    guess = int(input("2) Enter your guess: "))
    if guess < number:
        print("Too low")
        guess = int(input("3) Enter your guess: "))
        if guess < number:
            print("Too low")
            print(f"Incorrect. The correct number was {number}.")
        elif guess > number:
            print("Too high")
            print(f"Incorrect. The correct number was {number}.")
        else:
            print("Correct! You've guessed the number!")
    elif guess > number:
        print("Too high")
        guess = int(input("3) Enter your guess: "))
        if guess < number:
            print("Too low")
            print(f"Incorrect. The correct number was {number}.")
        elif guess > number:
            print("Too high")
            print(f"Incorrect. The correct number was {number}.")
        else:
            print("Correct! You've guessed the number!")
    else:
        print("Correct! You've guessed the number!")
elif guess > number:
    print("Too high")
    guess = int(input("2) Enter your guess: "))
    if guess < number:
        print("Too low")
        guess = int(input("3) Enter your guess: "))
        if guess < number:
            print("Too low")
            print(f"Incorrect. The correct number was {number}.")
        elif guess > number:
            print("Too high")
            print(f"Incorrect. The correct number was {number}.")
        else:
            print("Correct! You've guessed the number!")
    elif guess > number:
        print("Too high")
        guess = int(input("3) Enter your guess: "))
        if guess < number:
            print("Too low")
            print(f"Incorrect. The correct number was {number}.")
        elif guess > number:
            print("Too high")
            print(f"Incorrect. The correct number was {number}.")
        else:
            print("Correct! You've guessed the number!")
    else:
        print("Correct! You've guessed the number!")
else:
    print("Correct! You've guessed the number!")