Game

 avatar
unknown
python
2 years ago
467 B
5
Indexable
import random

number = random.randint(1, 20)
guess = 0
tries = 0

print("I'm thinking of a number between 1 and 20. Can you guess what it is?")

while guess != number:
    guess = int(input("Enter your guess: "))
    tries += 1
    if guess < number:
        print("Your guess is too low. Try again.")
    elif guess > number:
        print("Your guess is too high. Try again.")
    else:
        print("Congratulations! You guessed the number in", tries, "tries.")
Editor is loading...