Untitled

 avatar
unknown
plain_text
2 years ago
561 B
2
Indexable
import random

# generate a random number between 1 and 20
number = random.randint(1, 20)

print('Welcome to the Guess the Number game!')
print('I am thinking of a number between 1 and 20.')

# ask the user to guess the number
guess = int(input('Guess the number: '))

# keep guessing until the user gets it right
while guess != number:
    if guess < number:
        print('Too low!')
    else:
        print('Too high!')
    guess = int(input('Guess again: '))

# congratulate the user on guessing the number
print('Congratulations! You guessed the number.')