Python3 bug AttributeError: module 'math' has no attribute 'prod'

Sample code:

import math
a = math.prod([3,2])

Result:
AttributeError: module ‘math’ has no attribute ‘prod’

That’s because math.prod was introduced in Python 3.8 and CodinGame is using 3.7.4 as stated in the FAQ.
Language updates happen about once or twice a year.

1 Like

You can use operator.mul(3, 2).
If want it for a list L with a random number of elements you can do:
functools.reduce(operator.mul, L)

I think that version of IDE is inconsistent wih version of Python interpreter :grinning:

1 Like