I have the following for loop:
a = 0
b = 100
for x in my_list:
a = a * b + x
return a
My question is can I write it in single line.
I have tried:
a = my_list[0]
return sum((a*b + x) for x in my_list)
But is not doing what I want to.
from functools import reduce
res = reduce(lambda a, x: a * b + x, my_list, 0)