Question: my data structure is the following:

```
all= {
        'part1': {'act1': [0, 0], 'act2': [100, 0]},
        'part2': {'act1': [25, 1], 'act2': [100, 1]}, 
        'part3': {'act1': [25, 0], 'act2': [0, 1]}, 
        'part4': {'act1': [0, 0], 'act2': [0, 1]}
        }

```

My goal is to get the global sum of all the first items in the lists.

So far I have only managed to get the sum for each key of the top level dictionary, with this code:

```
for partData in all.values():
    depPart = 0
    for act in partData.keys():
        depPart += partData[act][0]   
    print(depPart)

```

It returns

```
100
125
25
0

```

while I would like to get the sum i.e. 250

Every attempt I have made to loop further in order to get this sum has resulted in errors.

Is looping the way to do it, if yes how? Or is there another / a better way to get to it?
Thanks

Answer: 
The reason is that firstly 

```
for partData in all.values():
    depPart = 0
    for act in partData.keys():
        depPart += partData[act][0]   
    print(depPart)

```

on line 2 `depPart=0` each time you get a value from all `print(depPart)` prints value everytime it sums every value inside each value so your code should have been 

```
depPart = 0
for partData in all.values():
    for act in partData.keys():
        depPart += partData[act][0]   
print(depPart)

```

hope it helps
You can use a list comprehension with `sum`:

```
d = {'part1': {'act1': [0, 0], 'act2': [100, 0]}, 'part2': {'act1': [25, 1], 'act2': [100, 1]}, 'part3': {'act1': [25, 0], 'act2': [0, 1]}, 'part4': {'act1': [0, 0], 'act2': [0, 1]}}
_sum = sum(sum(a for a, *_ in c.values()) for c in d.values())

```

Output:

```
#[100, 125, 25, 0]
250

```