這怎么回事? 請教
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec ?5 2015, 20:32:19) [MSC v.1500 32 bit (
Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> L = [75, 92, 59, 68]
>>> sum = 0.0
>>> for name in L:
... ? ? sum+=name
... print sum / 4
? File "<stdin>", line 3
? ? print sum / 4
? ? ? ? ^
SyntaxError: invalid syntax
>>>
怎么會報錯?
2016-02-20
L = [75, 92, 59, 68]
sum = 0.0
for score in L:
? ? print score
? ? sum=sum+score
? ? print sum
print sum/4
還有個地方不懂 在L里不是只有68才被運算嗎? 為了有了sum=sum+score就所有數被加起來
若變成
L = [75, 92, 59, 68]
for score in L:
? ? print score
print score/4
則其結果顯示68/4
我想我應該是漏掉了什么內容 能請各位幫忙下嗎?