感謝您閱讀本文。我試圖做this lab from programarcadegames.com你必須寫測驗。我完成了我的第一個問題,並得到一個語法錯誤。代碼如下:Python(3.2.3)If或Statement語法錯誤
print ("This is a quiz.")
x=0
questionOne=input("First question! How many fingers does a human have? "
if questionOne == "10" or questionOne.lower() == "ten":
print ("Correct! Good job!")
x+=1
else:
print ("Not quite... try the next one!")
print ("You got the following amount of questions right:",x)
當我運行它時,出現語法錯誤,Python shell編輯器窗口突出顯示了第四行末尾的冒號。刪除冒號會使其突出顯示下一行的打印內容。我也試圖消除或聲明,只是讓四行:
if questionOne == "10":
排除故障的緣故,但我結束了相同的錯誤和紅色的結腸。有任何想法嗎?批評?嘲笑評論?再次感謝您的閱讀。
編輯: 這不是.lowercase()
事情,固定的。
+1爲什麼? – 2012-08-09 03:31:11