Python-Programming-Lesson-Notes

5.4 Summing a list

Write a loop that calculates the sum of elements in a list by adding each element and printing the final value, so [124, 402, 36] prints 562

Solution
numbers = [124, 402, 36]
summed = 0
for num in numbers:
  summed = summed + num
print(summed)

Episode 5 exercise 5