发布时间:2019-07-29 18:47:02
代码如下
numbers=[1,2,3,4]
count=0
total=0
for x in numbers:
total=total+x
print(total/count)
你的count=0,total/count明显的除0错,异常消息为
ZeroDivisionError: division by zero
最简单的,改
count=4
就可以了
更合理的,在循环中加
count=count+1