Python sum()

The sum() in Python is an inbuilt function that takes an iterable and returns the sum of items in it. The sum () function adds the elements of an iterable and returns the sum. The sum of numbers in the list is required everywhere.

Syntax

sum(iterable, start)

The sum () function adds start and elements of the given  iterators from left to right.

The iterable may be  Python list,  tuple,  set, or  dictionary.

See the following examples.

How to find a sum of the list in Python

To find a sum of list in Python, use the sum() method. You just need to define the list and pass the list as a parameter to sum() function, and in return, you will get the sum of list items.

#python #python sum

Python sum(): Find Sum of List, Tuple, Set, Dictionary
1.55 GEEK