我的代码和示范的没什么区别,但就是出错,这是为什么呢
def average(*args):
n=0
sum=0.0
if len(args) == 0:
return sum
for x in args:
sum = sum + x
n = n + 1
return sum/n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
def average(*args):
n=0
sum=0.0
if len(args) == 0:
return sum
for x in args:
sum = sum + x
n = n + 1
return sum/n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2017-04-25
举报