I am new to python, I have a quite simple question.
how is it possible to use sum()
to do the following code in one line
total= 0.0
for record in myList:
a= record.a
b= record.b
total+= (a*b)
with myList
a list of objects that each one contains two attributes a
and b
I know we can do the following
sum([3,4,5]) == 3 + 4 + 5 == 12
but how to get the sum of multiplication?