[Tutor] product of all arguments passed to function call

Peter Otten __peter__ at web.de
Mon May 31 09:20:07 EDT 2021


On 31/05/2021 11:56, Manprit Singh wrote:

> Consider a problem where i have to find the product of all arguments passed
> to function call , where the function must be capable of accepting any
> number of arguments : My approach will be as follows :
> 
> def product(x, *y):
>      for ele in y:
>          x *= ele
>      return x

You might try to implement that with reduce() ;)



More information about the Tutor mailing list