With a dictionary with keys being names and values being the association they're part of as one of the parameters, and a person I'm interested as another parameter, the goal is to get all the people he's in the groups with into a new list.

For example,

```
connections =  {
    'Alex Dunphy': ['Orchestra', 'Chess Club'], 
    'Manny Delgado': ['Chess Club'], 
    'Cameron Tucker': ['Clown School', 'Wizard of Oz Fan Club'], 
    'Claire Dunphy': ['Parent Teacher Association'], 
    'Gloria Pritchett': ['Parent Teacher Association'], 
    'Phil Dunphy': ['Real Estate Association'], 
    'Mitchell Pritchett': ['Law Association']
}

```

What I did was invert the order so that it was key -> association and values being people that are involved in that association and trying to append to an empty list from there, but for some reason it's not working. The code is the following.

```
if person_to_networks != {}:
    ppl = []
    network_to_people = {}

    for key in person_to_networks:
        for i in range(len(person_to_networks[key])):
            if person_to_networks[key][i] not in network_to_people:
                ppl.append(key)
                network_to_people[person_to_networks[key][i]] = [key]
            elif person_to_networks[key][i] in network_to_people:
                network_to_people[person_to_networks[key][i]].append(key)

for net in network_to_people:
    for i in range(len(network_to_people[net])):
        if person in network_to_people[net]:
            test.append(network_to_people[net][i])
print(test)

```

The output is:

```
[]

```

The desired output is:

```
['Manny Delgado', 'Alex Dunphy', 'Alex Dunphy']

```

if the person selected was Alex Dunphy

Any tips and stuff?