爲什麼這個中斷不會結束,而是返回到開始?Python中斷函數並沒有結束,而是真的
while True:
print('This is a quiz')
print('What is your name?')
Name = input()
print('Hello ' + Name + ', The quiz will now begin')
import time
time.sleep(2)
question1 = "Question one: "
answer1 = "True" and "true"
print(question1)
qanswer = input()
if qanswer != answer1:
print('Sorry, the answer is: ' + answer1)
break
if answer1 == qanswer:
print("Correct! Here's the next question")
我對Python很新,所以我認爲這只是一個簡單的濫用條款。
'answer1 =「True」and「true」'這不符合你的想法。嘗試在創建變量後打印「answer1」。如果要將用戶輸入與兩個不同的字符串進行比較,則需要將輸入與兩個字符串進行比較。 [文檔和](http://docs.python.org/2/library/stdtypes.html#boolean-operations-and-or-not) – unholysampler
我不認爲這意味着你的想法:'answer1 =「真」和「真」'。 –