My dictionary looks like this:
docScores = {0:[{u'word':2.3},{u'the':8.7},{u'if':4.1},{u'Car':1.7}],
1:[{u'friend':1.2},{u'a':5.2},{u'you':3.8},{u'person':0.8}],
...
29:[{u'yard':1.5},{u'gardening':2.8},{u'paint':3.7},{u'brush':1.6}]
}
I want to sum the values of each inner dict for each list and store it in a new dict, with the new dict having key values of {0:2.3+8.7+4.1+1.7, 1:1.2+5.2+3.8+0.8, ... etc} i.e.
for x in docScores[0]: #{0:
for x in docScores[0][0].values(): #{,2.3}.
sum = sum+x #where sum = 0 before loop
docSum[0] = sum
repeat this loop for every document
Any variation that I have tried is giving me unexpected outputs. Can anyone give me the correct syntax for this?