Skip to content

Files

Latest commit

35b44eb · May 27, 2017

History

History
19 lines (17 loc) · 671 Bytes

File metadata and controls

19 lines (17 loc) · 671 Bytes

Python Sum

The function sum(iterable) adds all of the items in a Python iterable (list, tuple, and so on) from left to right and returns the total.
There is an optional second argument, start, that defaults to 0 and is added to the total.
The iterable‘s items are normally numbers, and the start value is not allowed to be a string.

>>> numbers = [1, 2, 3, 4, 5]
>>> sum(numbers)
15
>>> sum(numbers, 1)
16
>>> sum(numbers, 10)
25

Instructions:
There are two lists of numbers.
Find the sum of all of the items in both lists and assign that value to a variable named total.