I am trying to create a guessing game and it works all well. However, I want to include a part where if a user puts a number above 100, you are told that your choice should be less than 100. The code below doesn't seem to do that. What am I doing wrong?
import random
comGuess = random.randint(0,100)
while True:
userGuess = int(input("Enter your guess :"))
if userGuess > comGuess:
print ("Please go lower")
elif userGuess < comGuess:
print ("Please go higher")
elif userGuess > (100):
print ("Your choice should be less than 100")
elif userGuess <1:
print ("Your choice should be less than 100")
else:
print ("Great, you got it right")
break
Aucun commentaire:
Enregistrer un commentaire