def positive_pairs(l, k=None): result = [] for i in range(len(l)): if len(result) == k: break if l[i] > 0: for j in range(i+1, len(l)): if len(result) == k: break if l[j] > 0: result.append((l[i], l[j])) return result