求解答,为什么会运行失败,谢谢
```
def average(*args):
n = len(args)
s = 0.0
a = 0
if n == 0:
return s
while a <= n:
s += args[a]
a += 1
return s / n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
```
```
def average(*args):
n = len(args)
s = 0.0
a = 0
if n == 0:
return s
while a <= n:
s += args[a]
a += 1
return s / n
print average()
print average(1, 2)
print average(1, 2, 2, 3, 4)
```
2018-07-04
举报