Continue 循環報錯
L = [75, 98, 59, 81, 66, 43, 69, 85]
sum = 0.0
n = 0
for x in L:
if x < 60:
????????continue
? ? sum+=x
? ? n = n + 1
print sum / n
這是課上的代碼,目的是統計及格分數的平均分,剔除小于60的值。運行的時候報錯 “?sum+=x”這句報錯“unindent does not match any outer indentation level”問題是我縮進都對的好好地啊,求教一下大佬們。
2017-06-30
我覺得還是縮進問題:
for后邊需要縮進,然后if后面的continue也需要縮進。
然后運算結果是79.0
我也剛學python,哈哈
2017-06-30
? File "l01.py", line 5
? ? if x < 60:
? ? ?^
IndentationError: expected an indented block
if前面應該有縮進