Update average.py (#908)

Reduced lines of code and extra processing on the line: n += 1
This commit is contained in:
Adeoti Ayodeji
2019-06-22 12:42:28 +08:00
committed by John Law
parent a99acae32d
commit 12a16d63b7
+2 -3
View File
@@ -1,11 +1,10 @@
def average(nums):
sum = 0
n = 0
for x in nums:
sum += x
n += 1
avg = sum / n
avg = sum / len(nums)
print(avg)
return avg
def main():
average([2, 4, 6, 8, 20, 50, 70])