2013-08-31 56 views
0

我在if語句出現語法錯誤Python語法錯誤:一個簡單的if語句

print "Welcome to the English to Pig Latin translator!" 

original = raw_input("Please enter a word to be translated: ") 
word_length = len(original) 

def length_check(): 
    If (word_length) > 0 : <-- This colon brings up the following error: 
     return original 


File "python", line 7 
    If (word_length) > 0 : 
         ^
SyntaxError: invalid syntax 

回答

5

If應改爲if。觀察小寫字母i

>>> If True: 

SyntaxError: invalid syntax 
>>> if True: 
     print True 


True 

您可能要了解The Python Doc's entry on Control Flow

+0

謝謝!我是對的,我是一個白癡! – user2735954

+0

@ user2735954:很高興我有幫助。不要忘記[接受答案](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)。 :) –