为什么这个循环体会输出3 12
def average(*args):
sum = 0.0
if len(args)==0:
return sum
for x in args:
n = 0
sum = sum + x
n = n + 1
return sum / n
print average(1, 2)
print average(1, 2, 2, 3, 4)
def average(*args):
sum = 0.0
if len(args)==0:
return sum
for x in args:
n = 0
sum = sum + x
n = n + 1
return sum / n
print average(1, 2)
print average(1, 2, 2, 3, 4)
2019-01-29
举报