• having loaded this script site doesn't respond

Question related to mission How to Find Friends

 
def check_connection(network, first, second):
elements = set()
future = []
neighbours = {}
for i in network:
    for m in i.split('-'):
        elements.add(m)

for i in elements:
    neighbours[i]=set()


for element in elements:
    for i in network:
        if element in i.split('-'):
            for k in i.split('-'):
                neighbours[element].add(k)
if first in neighbours: 
    for i in neighbours[first]: 
            if i == second: 
                return True 
            else: 
                future.append(i) 

while len(future) != 0:
    for i in future[:]: 
        for g in neighbours[i]: 
                if g == second: 
                    return True

                else: 
                    future.append(g) 
        future.remove(i)


else:

return False
10