2012-11-07 145 views
0
A=int(input('Enter the first of three numbers: ')) 
B=int(input('Enter the second of three numbers: ')) 
C=int(input('Enter the third of three numbers: ')) 
list=[A,B,C] 
SL=sorted(list) 
if SL[0]<0: 
    if SL[1]-1==SL[0]: 
     print (list('they are good')) 
    else: print (list('not good')) 
elif SL[2]-1==SL[1]: 
    print (list('they are good') 
else: print (list('not good')) 

我不斷地得到一個語法錯誤在最後一行之間else和:我不知道爲什麼它是錯誤的,當我有上面完全相同的行3行。任何幫助非常感謝。Python:語法錯誤?

+2

你應該真的發佈確切的錯誤信息。 – Miguel

+2

它只是支架,謝謝你們。 – user1804787

回答

4

你缺少在倒數第二行結束括號,它應該是:

print (list('they are good')) 
1

你錯過了第二至最後一行末尾的「)」。

1
elif SL[2]-1==SL[1]: 
    print (list('they are good') 

缺少在打印語句結尾關閉)