为什么在加这个对于无参数输入的条件不添加返回,而改变成打印会报错呢?
def average(*args):
sum = 0
if len(args) == 0:
print('Error')
for i in args:
sum += i
avg = sum / len(args)
return avg
print average()
def average(*args):
sum = 0
if len(args) == 0:
print('Error')
for i in args:
sum += i
avg = sum / len(args)
return avg
print average()
2021-08-15
举报