sum()
function is used to find the adds the items of an iterable and returns the sum in Python for the given input.
sum()
function is a part of Python Built-in Functions.
Syntax of sum()
Function
The syntax of
sum()
function in Python is:
sum(iterable, start)
Parameters of sum()
Function in Python
x
– Where x
is any valid . This parameter is required.
Compatibility
sum()
function is available and compatible with both Python 2.x
and 3.x
.
Return Value of sum()
Function in Python
sum()
function returns adds the items of an iterable and returns the sum for the given input.
Python sum()
Function Example 1
Example CODE
Output:
Python sum()
Function Example 2
Example CODE
Output: