我的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
答案 0 :(得分:5)
If
应更改为if
。请注意小写i
。
>>> If True:
SyntaxError: invalid syntax
>>> if True:
print True
True