翻译说错误的语法,但我无法找到错误

时间:2017-10-02 22:32:50

标签: python

print 'Welcome to the Pig Latin Translator!'

# Start coding here!
original = raw_input("Enter a word:")
if len(original) > 0 :
  print raw_input

  else:
    print "empty"

这就是翻译所说的:

File "python", line 8
    else:
       ^
SyntaxError: invalid syntax

我做错了什么?

1 个答案:

答案 0 :(得分:4)

else 的缩进必须跟随

这对于Python来说一般来说,缩进很重要。

print 'Welcome to the Pig Latin Translator!'

# Start coding here!

original = raw_input("Enter a word:")

if len(original) > 0:
    print raw_input

else:
    print "empty"