我正在 Codecademy 上学习 Python,我应该在显示“你输了”之前给用户 3 次猜测。我认为我的代码允许 3 个条目,但网站显示“糟糕,再试一次!您允许用户 3 次猜测,还是您错误地检测到正确的猜测?” 除非用户在 3 次试验内猜对了。有人可以告诉我有什么问题吗?
from random import randrange
random_number = randrange(1, 10)
count = 0
# Start your game!
guess= int(raw_input("Please type your number here:"))
while count < 2:
if guess==random_number:
print "You win!"
break
else:
guess=int(raw_input("Please guess again:"))
count+=1
else:
print "You lose!"
print random_number