#python game
import random
a = random.randint(1,100)
b = int (input("guess the number"))
while True :
if a == b:
print ("you guessed it correct \n you won the game!!")
break
elif a>= b:
print ("you guesssed it too high")
else :
print ('you guessed it too low')
-
You have to get the input in the loop rather than before the loop.Rabbid76– Rabbid762020-09-22 17:37:51 +00:00Commented Sep 22, 2020 at 17:37
Add a comment
|
2 Answers
You have to get the input in the loop rather than before the loop:
a = random.randint(1,100)
# b = int (input("guess the number")) <--- DELETE
while True :
b = int (input("guess the number")) # <--- INSERT
if a == b:
print ("you guessed it correct \n you won the game!!")
break
elif a >= b:
print ("you guesssed it too high")
else:
print ('you guessed it too low')