Lesson 13: Guess game

posted Mar 13, 2019, 8:04 AM by Attila Lengyel
import random as r

a = r.randint(0,100)

print("I thought of a number between 0 and 100.")
print("Guess the number!")

counter = 0
correct = False

while(correct == False):
guess = int(input(":"))
counter = counter + 1
if guess == a:
correct = True
elif guess < a:
print("It is too low")
else:
print("It is too high")
if correct:
print("Good guess. The nunber is:", a)
print("You tried", counter, "times")

Comments