0

我的 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
4

1 回答 1

5

If应改为if. 观察小写i

>>> If True:

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


True

您可能需要阅读The Python Doc's entry on Control Flow

于 2013-08-31T17:42:18.047 回答