Skip to content

Commit

Permalink
Update average.py (TheAlgorithms#908)
Browse files Browse the repository at this point in the history
Reduced lines of code and extra processing on the line: n += 1
  • Loading branch information
lordsarcastic authored and poyea committed Jun 22, 2019
1 parent a99acae commit 12a16d6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions maths/average.py
Original file line number Diff line number Diff line change
@@ -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])
Expand Down

0 comments on commit 12a16d6

Please sign in to comment.