def answer(l):
    num_dict = {}
ans_set = set()
for a2, a in enumerate(l):
    num_dict[a, a2] = []
for x2, x in enumerate(l):
    for y2, y in enumerate(l):
        if (y, y2) != (x, x2) and y % x == 0:
            pair = y, y2
num_dict[x, x2].append(pair)
for x in num_dict:
    for y in num_dict[x]:
        for z in num_dict[y]:
            ans_set.add((x[0], y[0], z[0]))
return len(ans_set)
What's the most efficient way to find factors in a list?