Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Solution 1 for Number Guessing

import random

hidden = random.randrange(1, 21)
while True:
    user_input = input("Please enter your guess: ")
    print(user_input)

    guess = int(user_input)
    if guess == hidden:
        print("Hit!")
        break

    if guess < hidden:
        print("Your guess is too low")
    else:
        print("Your guess is too high")