2016-12-05 91 views
-2
A = int(input()) #recom. sleep time 
B = int(input()) #unrecom. sleep time 
H = int(input()) #fact. slept 
if (A <= H < B): 
    print('Fine') 
elif (A <H>= B): 
     print('too much') 
else (A > H < B): 
print('not much') 

Error: 
File "<ipython-input-9-12133f4a4c3d>", line 8 
    else(A > H < B): 
     ^
SyntaxError: invalid syntax 

夥計們不要粗魯,我很理財,開始學習編程:) 我看不到通過錯誤檢查的代碼和這個之間的區別。Python。菜鳥。語法錯誤

+5

'else'不需要測試。它是'else:',總是。如果您需要另一個測試,請使用'elif'。你也有縮進問題。 –

+0

謝謝!我很抱歉在您的問題解答中發送垃圾郵件,但我自己沒有找到答案。 –

回答

1

您正在使用else進行測試。您應該使用elif

A = int(input()) #recom. sleep time 
B = int(input()) #unrecom. sleep time 
H = int(input()) #fact. slept 
if A <= H < B : 
    print('Fine') 
elif (A <H>= B): 
    print('too much') 
elif A > H < B: 
    print('not much')