PHP » PYTHON |
login |
register |
about
|
PYTHON array_product
is this article helpful?
|
Python replacement for PHP's array_product
[
edit
| history
]
def array_product(lst): if not lst: return 0 # in PHP, the empty array product is 0; mathematically the correct result would be 1 else: reduce(lambda a,b: a*b, lst) array_product(PHP 5 >= 5.1.0) array_product — Calculate the product of values in an array Descriptionarray_product() returns the product of values in an array. Parameters
Return ValuesReturns the product as an integer or float. Examples
Example #1 array_product() examples
<?php The above example will output: product(a) = 384
|
more
Recently updated
more
Most requested
more
Last requests
|