from random import randrange

print("Try to guess a number from 1 to 999!")


def play():
    number = randrange(1, 1000)
    guess = -1
    while guess != number:
        guess = int(input("Your guess: "))
        if guess < number:
            print("Too low.")
        elif guess > number:
            print("Too high.")
    print("You win!")

play()
while True:
    ans = input("Do you wanna play again? [Y/n] ") + ' '
    if ans[0] == 'y':
        play()
    elif ans[0] == 'n':
        print("Have a nice day!")
        exit()