Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
One possible program:
import random
secret = random.randint(1, 100)
print("I'm thinking of a number from 1 to 100.")
while True:
guess = int(input("Your guess: "))
if guess < secret:
print("Too low!")
elif guess > secret:
print("Too high!")
else:
print("Correct! Well done.")
break