Every sublist means that they are friends and now I want to create a function def is_connected_via_friendships_with
that checks if they are connected via friendships with another person. For example Marie is friends with Lucas. She is friends with Peter and Peter with Julie. So the function needs to return True
for Marie and Julie. Also note that I can't use import
for this. Thank you in advance.
network = {'friendships' :[['Marie', 'Lucas'], ['Lucas', 'Patsy'], ['Emma', 'Lucas'], ['Emma', 'Kevin'], ['Peter', 'Emma'], ['Peter', 'Lucas'], ['Peter', 'Julie'], ['Suzy', 'Tobias']]}
print (is_connected_via_friendships_with(network, 'Marie', 'Julie')) # true
print (is_connected_via_friendships_with(network, 'Julie', 'Tobias')) # false
print (is_connected_via_friendships_with(network, 'Julie', 'Frank')) # false