2012-08-02 157 views
-4

我想不通爲什麼它是說這個詞的選項無效語法我所有的if語句無效的語法---蟒蛇

Options = raw_input("Would you like to Square, Cube, Multiply, or Divide? ") 

If Options == "Square" or Options == "square": 
Square = int(raw_input("What number would you like to Square? ")) 
Answer1 = Square ** 2 
print "The answer is :%d" %Answer1 

if Options == "Cube": 
Cube = int(raw_input("What number would you like to Cube ")) 
Answer2 = Cube ** 3 
print "The answer is :%d" %Answer2 

if Options == "Multiply": 
Multiply1 = int(raw_input("What is the first number to multiply? ")) 
Multiply2 = int(raw_input("What is the second number to multiply?  ")) 
Answer3 = Multiply1 * Multiply2 
print "The answer is :d%" %Answer3" 
+2

閱讀基本的Python教程在這裏會很有幫助 – 2012-08-02 18:05:08

+1

中斷器指向錯誤所在的位置。利用此功能。 – 2012-08-02 18:07:23

回答

7

Python是區分大小寫的。 If需要是if。你的代碼也需要正確縮進。

+4

Python也是空白區域敏感的,所以按下每個if下的選項卡一次。 – VoronoiPotato 2012-08-02 18:02:12

+0

非常感謝。我已經在我的版本中正確縮進了,但是它說我必須以某種方式發佈我的問題,所以我只是改變了它。 – user1539175 2012-08-02 18:30:28

+0

要在問題中發佈代碼,請從您的編輯器複製並粘貼該代碼,突出顯示它,然後點擊代碼格式化按鈕。不要刪除格式,特別是對於Python代碼。 – geoffspear 2012-08-02 18:33:09