Tom Ritchford
Jul 20, 2023

--

Rather, "Horrifying and disturbing" :-D

eval is tremendously slow; it is dangerous.

functools.reduce(operator.mul, range(1, 6), 1)

is one solution:

(prod := 1) and [prod := prod * i for i in range(1, 6)]

is another.

--

--

Responses (1)