- reduce() is a python function which apply on the particular function to manipulate the given sequence.
-It is defined in functools module.
Syntax-
functools.reduce(function,sequence)
-It return final value after iteration of the whole sequence through the function.
program-
#import the functools module
import functools
#define a function which return sum of two number
def f(x,y):
return x+y
#take input of the list
print("Enter number in list")
n=map(int,input().split())
x=functools.reduce(f,n)
print("Sum of list is :",x)
Enter number in list
1 2 3 4
Sum of list is : 10