这为啥不行,每传入一个数,就给y加一,为什么返回的时候y一直是0
def average(*args):
sum=0.0
y=0
if args == 0:
print 0
else:
for x in args:
sum+=x
y+=1
return sum/y
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
def average(*args):
sum=0.0
y=0
if args == 0:
print 0
else:
for x in args:
sum+=x
y+=1
return sum/y
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2018-12-29
举报