Question: I come to this point when I was making a simple calculator. I did a simple program to sum the list of numbers as follows, But the program for multiplication is a little bit long.

So can anybody have any idea how to make short program to multiple list of numbers in python. Here is my code what looks like.

```
def calculate(oper,*nm):
    return oper(nm)

add=lambda x:sum(x)

def mult(lst):
    tmp=1
    for i in lst:
        tmp*=i
    return tmp

```

calculate(add,2,34,2)

calculate(mult,8,5,7)

Answer: 
Really, you do not need to define `calculate` because Python already has a name for it: [reduce](http://docs.python.org/2/library/functions.html#reduce). 

```
def calculate(oper, *nm):
    return reduce(oper, nm)

In [6]: import operator

In [7]: calculate(operator.add, 2, 34, 2)
Out[7]: 38

In [8]: calculate(operator.mul, 8, 5, 7)
Out[9]: 280

```

Note: In Python3, `reduce` has been moved to the [functools module](http://docs.python.org/3.3/library/functools.html?highlight=functools%20reduce#functools.reduce). (Thanks to @ErikRoper for pointing this out.)
You can use the in-built `reduce` function, which takes a callable, a list and an optional starting element. It calls `callable` with a tuple `(elem, result)` where element is the `ith` element from the list and `result` is the result so far.

```
reduce(lambda item,prod: item * prod, range(1, 5), 1)
Out[2]: 24

```

So the above would call the lambda function first with `(1,1)`, then with `(2,1*1)` then `(3,2*1)` and finally `(4,3*2)`

So you'd define `add` and `mult` and replace your `calculate` with the built-in reduce

```
add = lambda item,cumul_sum: item + cumul_sum
mult = lambda item,product: item * product 
reduce(add, range(1,5), 0)
Out[5]: 10
reduce(mult, range(1,5), 1)
Out[6]: 24

```

<http://docs.python.org/2.7/library/functions.html?highlight=reduce#reduce>