From 12a16d63b7bdc1da0e0b215dfd5d8b938234f4ed Mon Sep 17 00:00:00 2001 From: Adeoti Ayodeji <33290249+Lord-sarcastic@users.noreply.github.com> Date: Sat, 22 Jun 2019 05:42:28 +0100 Subject: [PATCH] Update average.py (#908) Reduced lines of code and extra processing on the line: n += 1 --- maths/average.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/maths/average.py b/maths/average.py index dc70836b5..d15601dd6 100644 --- a/maths/average.py +++ b/maths/average.py @@ -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])