2017-02-18 84 views
-3
rawAge = input("Enter your age: ") 

age = int(rawAge) 

if age > 20: 
    print("You are older than 20 years old") 
    else: 
    print("You are too young") 

我越来越:其他:语法错误的Python

C:\Python36\programs>py test.py 
    File "test.py", line 8 
    else: 
    ^
SyntaxError: invalid syntax 

每一个地方我看它告诉我不喜欢这样,我缺少什么?

+0

你的其他不正确缩进的问题。它应该与if子句排成一行 – Neelik

+0

'else:'应该像'if:'一样缩进,所以左边有四个空格。 –

回答

3
rawAge = input("Enter your age: ") 

age = int(rawAge) 

if age > 20: 
    print("You are older than 20 years old") 
else: 
    print("You are too young") 

缩进

+0

感谢刚刚注意到这个问题在Python中,我的IDE格式不正确。 – WastedHat