def average(*args): sum = 0 if len(args) == 0: return sum for item in args: sum += item avg = sum / len(args) return avg print(average(1,2,3,4))
def average(*args):
sum = 0.0
if len(args)==0:
return None
for item in args:
sum += item
avg = sum / len(args)
return avg
print(average(1, 2))
print(average(1, 2, 2, 3, 4))
print(average())