ids = list() for aID, A in enumerate(sAR): for eID, E in enumerate(sER): s = satisfy_conditions(A, E, conditions) if s : ids.append((aID, eID))