2012-08-09 30 views
2

感謝您閱讀本文。我試圖做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

+1爲什麼? – 2012-08-09 03:31:11

回答

8

您在上一行(input的行中)缺少右括號。

+0

謝謝你的回答!代碼現在完美運行。 – user1586423 2012-08-09 03:31:41

+2

@ user1586423如果這解決了你的問題,你應該考慮[接受這個答案](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235)。它會用一些積分獎勵雙方,並將此問題標記爲已解決。這是SO的「謝謝」機制:) – Levon 2012-08-09 03:32:35

+0

做完了,對不起! – user1586423 2012-08-09 03:52:50