Skip to content

How to sum all the numbers in 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
See also  How to convert int to string in Python?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.