Challenge: Guessing Game Judge

Lab Python Intermediate 20 points

Play the judge in a guessing game. The first line is the secret number; each following line is a guess. For each guess print Too low, Too high or Correct after <n> guesses. Stop reading as soon as a guess is correct. Ignore guesses that aren't whole numbers – print Not a number and don't count them.

Input

The secret number, then the guesses, one per line. The last guess is always correct.

Output

One line per guess.

Example

Input

37
50
25
37

Output

Too high
Too low
Correct after 3 guesses
Sample input available Sample output available
Editor
Python

Hints

Use while True and break on the correct guess.

Wrap int(input()) in try/except ValueError.

Only increase the counter for real numbers.

Solution explanation

This is the game from the project lesson, with the input coming from the checker instead of a player.

Show solution
secret = int(input())
tries = 0
while True:
    try:
        guess = int(input())
    except ValueError:
        print("Not a number")
        continue
    tries += 1
    if guess < secret:
        print("Too low")
    elif guess > secret:
        print("Too high")
    else:
        print(f"Correct after {tries} guesses")
        break
Output
Answer
HOME LEARN COMMUNITY DASHBOARD