Find sum of numbers in list
To find the sum of numbers in given list in Python, pass the list as argument to sum() builtin function. The function returns an integer representing the sum of items in the list.
The syntax of the expression to find the sum of numbers in the list x
is
sum(x)
Examples
1. Find sum of items in list x
In the following program, we take a list x
, and find the sum of numbers in the list x
.
Python Program
x = [4, 0, 5, 7, -1, 3]
result = sum(x)
print(result)
Run Output
18
Summary
In this tutorial of Python Examples, we learned how to find the sum of numbers in the given list using sum() builtin functions, with the help of well detailed examples.
Related Tutorials
- Python List of Functions
- Python – Count the items with a specific value in the List
- Python – Get Index or Position of Item in List
- Python – How to Create an Empty List?
- How to Sort Python List?
- Python – List of Strings
- Python List without Last Element
- How to Reverse Python List?
- Python List of Dictionaries
- How to Append List to Another List in Python? – list.extend(list)