我發現這是爲了生成隨機數。雖然沒有表達和布爾理解
def main():
randomNumber = randint(1,100)
found = False
while not found:
userGuess = input("")
if userGuess == randomNumber:
print "You win."
found = True
elif
.....
else
.....
所以我的問題是'雖然沒有找到',我不覺得這是本能的。 更多的本能,但不工作應該是這樣的:
found = False
while found
- >環路工作時發現是假的
有人能解釋一下嗎?
然後你應該寫'while found == false',這是你的文本的直譯,「發現是錯誤的」。 –
修復您的縮進; 'while found'表示'while found found == True','while not found'表示'while found == False' –