I have got a list containing nested lists like this :
[ [datetime.datetime(2000, 12, 10, 0, 0), 0.0011] , [datetime.datetime(2000, 12, 11, 0, 0), 0.0013 , [datetime.datetime(2000, 12, 12, 0, 0), 0.0014]]
etc..
How do I go about adding sub elements 2 by 2 like this :
sum(0.0011,0.0013) + 0.0014
then taking the result of this sum and adding it to the next sub element ?
I`m basically trying to compound the values .
thanks!
The easiest way to do this is with the
sum()builtin and a generator expression:Edit:
If you want to print out the result of each stage of the summation, you want to use
functools.reduce()(which, in 2.x is thereducebuiltin).Which gives us: