2013-09-24 14 views
1

在最後一行我想圓輸出小數點後一位,但是當我測試這方面,我得到一個意外的EOF錯誤。請幫助?蟒蛇 - 表達式的舍入值 - 意外EOF

count = 0 
scoreSum = 0 
score = 0 
while score != 999: 
    score = float(input("Enter test score or enter 999 to finish: ")) 
    if score > 0 and score < 100: 
     scoreSum += score 
     count += 1 
    elif (score <0 or score > 100) and score != 999: 
     print("This score is invalid, Enter 0-100") 
else: 
    print ("your average is: ", round((scoreSum/count), 2) 
+0

這是太容易了,你有3個正好一分鐘內:)同樣的答案。給我們更好的問題!我確實承認Python的錯誤信息不太有用。 –

+0

哈哈,我只是一個初學者,給它時間。 – MrAlex42

回答

2

最後一行是你的問題 - 你需要一個右括號:

print ("your average is: ", round((scoreSum/count), 2)) 
#           right here^

其實,你可以讓你的代碼行是這樣的:

print("your average is: ", round(scoreSum/count, 2)) 

沒有需要那些額外的括號。

0

您在月底缺少一個右括號:

print ("your average is: ", round((scoreSum/count), 2)) 
                 ^THIS