Guessing Game

Lab Python Intermediate 20 points

The secret number is 42. Read guesses one per line. For each guess print Too low or Too high; when a guess is right print Correct after N guesses and stop reading.

Input

Guesses, one per line; the last one is 42.

Output

One line per guess.

Example

Input

50
25
42

Output

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

Hints

Count guesses as you go.

break out of the loop when the guess is right.

Solution explanation

This is the classic game loop: read, compare, give feedback, repeat until done.

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