Из словаря следующего вида необходимо извлечь друзей друзей юзера
{'юзер1': [[список_друзей_юзера1], [список_игр_юзера1]], 'юзер2': [[список_друзей_юзера2], [список_игр_юзера2]], ...}
net = {'Freda': [['Olive', ' John', ' Debra'], ['Starfleet Commander', ' Ninja Hamsters', ' Seahorse Adventures']], 'Ollie': [['Mercedes', ' Freda', ' Bryant'], ['Call of Arms', ' Dwarves and Swords', ' The Movie: The Game']], 'Debra': [['Walter', ' Levi', ' Jennie', ' Robin'], ['Seven Schemers', ' Pirates in Java Island', ' Dwarves and Swords']], 'Mercedes': [['Walter', ' Robin', ' Bryant'], ['The Legend of Corgi', ' Pirates in Java Island', ' Seahorse Adventures']], 'Levi': [['Ollie', ' John', ' Walter'], ['The Legend of Corgi', ' Seven Schemers', ' City Comptroller: The Fiscal Dilemma']], 'Jennie': [['Levi', ' John', ' Freda', ' Robin'], ['Super Mushroom Man', ' Dinosaur Diner', ' Call of Arms']], 'Olive': [['John', ' Ollie'], ['The Legend of Corgi', ' Starfleet Commander']], 'John': [['Bryant', ' Debra', ' Walter'], ['The Movie: The Game', ' The Legend of Corgi', ' Dinosaur Diner']], 'Robin': [['Ollie'], ['Call of Arms', ' Dwarves and Swords']], 'Bryant': [['Olive', ' Ollie', ' Freda', ' Mercedes'], ['City Comptroller: The Fiscal Dilemma', ' Super Mushroom Man']], 'Walter': [['John', ' Levi', ' Bryant'], ['Seahorse Adventures', ' Ninja Hamsters', ' Super Mushroom Man']]}
Моя функция
def get_secondary_connections(net, user): secondary_connections = [] if user not in net: return None if len(net[user][0])<1: return [] for con in net[user][0]: for c in net[con][0]: if c not in secondary_connections: secondary_connections.append(c) return secondary_connections
При
print(get_secondary_connections(net, 'Bryant'))
Буду благодарна за помощь.