谁能告诉我这个为什么执行的答案是错的
def average(*args):
sum=0.0
for x in args:
if len(args)==0:
return sum
else:
sum=sum+x
return sum/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
def average(*args):
sum=0.0
for x in args:
if len(args)==0:
return sum
else:
sum=sum+x
return sum/len(args)
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
2018-03-07
举报