so I'm writing this code for a game I'm working on. But I can't figure out what i did wrong. When I run this code, even if I do type in the right number it still wrong. I think there's something error with my while loop. Can anybody help me out a bit?Will be really appreciated By the way I am very new to python.
The code are as following:
Guess_Count = 0
Guess_Limit = 7
Store_Guess_Nam = []
Guess_Nam = int()
import random
Nam = list(range(1, 25))
Random_Nam = random.choice(Nam)
print (Random_Nam)
while Guess_Count < Guess_Limit:
if Guess_Nam < Random_Nam:
Guess_Nam = int(input("Enter Number: "))
print("Number too small.")
Guess_Count += 1
elif Guess_Nam > Random_Nam:
Guess_Nam = int(input("Enter Number: "))
print("Number too big.")
Guess_Count += 1
elif Guess_Nam == Random_Nam:
Guess_Nam = int(input("Enter Number: "))
print("Correct")
break
else:
print("Out of guess.")
Aucun commentaire:
Enregistrer un commentaire