print ‘average’ 放置位置?
>>> d={'Adam':95,'Lisa':85}
>>> sum= 0.0
>>> for k,v in d.iteritems():
... sum= sum + v
... print k,':',v
... print 'average',':',sum / len(d)
File "<stdin>", line 4
print 'average',':',sum / len(d)
^
SyntaxError: invalid syntax
>>> d={'Adam':95,'Lisa':85}
>>> sum =0.0
>>> for k,v in d.iteritems():
... sum=sum+v
... print k,':',v
...
Lisa : 85
Adam : 95
>>> print 'average',':', sum /len(d)
average : 90.0
print 'average', ':', sum / len(d) 不是应该处于for循环内吗,退出for输入那sum的值不是0.0吗,0.0/len(d)不是0吗