Python – Find sum of numbers in list

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 Code Copy

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

Code copied to clipboard successfully 👍