Why isn't there a built-in product()?
Michael F. Stemper
michael.stemper at gmail.com
Sat Jul 9 09:25:40 EDT 2022
On 07/07/2022 19.06, Oscar Benjamin wrote:
> On Thu, 7 Jul 2022 at 22:55, Michael F. Stemper
> <michael.stemper at gmail.com> wrote:
>>
>> sum() is wonderful.
>> I understand that there is no product() or prod(). Does anybody
>> here know why that was not included in the language? It seems
>> as if it would be useful, so there must have been some rationale
>> for that decision.
>
> There is math.prod:
>
> >>> from math import prod
> >>> prod([1, 2, 3, 4])
> 24
>
> https://docs.python.org/3/library/math.html#math.prod
I did not know that. Thanks.
--
Michael F. Stemper
Outside of a dog, a book is man's best friend.
Inside of a dog, it's too dark to read.
More information about the Python-list
mailing list