Create your own
teaching resources

Sign up for a free account to try! It takes less than 20 seconds

Teacherbot 05 Apr, 04:16:55

import random

number = random.randint(1, 100) guessCounter = 0

print(“Guess the number between 1 and 100!”)

while True: guess = int(input(“Enter your guess: “)) guessCounter += 1

if guess == number:
    print(guess, "is correct, you win!")
    print("You got it in", guessCounter, "guesses.")
    break
elif guess > number:
    print("Too high!")
else:
    print("Too low!")