how to sum up a list of values in python code example
Example 1: how to calculate the sum of a list in python
# Python code to demonstrate the working of
# sum()
numbers = [1,2,3,4,5,1,4,5]
# start parameter is not provided
Sum = sum(numbers)
print(Sum) # result is 25
# start = 10
Sum = sum(numbers, 10)
print(Sum) # result is 10 +25 = 35
Example 2: how to add all values in a list python without using sum function
def int_list(grades): #list is passed to the function
summ = 0
for n in grades:
summ += n
print summ