a = dict()
uid1 = 1
uid2 = 2
a[uid1] = {}
a[uid2] = {}
iid1 = 45
iid2 = 98
iid3 = 3
iid4 = 82
iid5 = 11
a[uid1][iid1] = 125
a[uid2][iid2] = 7
a[uid1][iid3] = 4
a[uid2][iid4] = 10
a[uid2][iid5] = 20
get a:
{1: {45: 125, 3: 4}, 2: {98: 7, 82: 10, 11: 20}}
What I want to get is to calculate the sum of 125+4=129 and 7+10+20=37
I've tried this:
for u,items in a.items():
for i,counts in items.items():
for count in counts:
print(count)
got a notice like this:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-48-8b6a2dace81e> in <module>
1 for u,items in a.items():
2 for i,counts in items.items():
----> 3 for count in counts:
4 print(count)
TypeError: 'int' object is not iterable
Now I don't know how to proceed.