How to combine elements from 2 lists together with a condition
combs = [] list1 = [1,2,3] list2 = [3,1,4] for x in list1: for y in list2: if x != y: combs.append((x, y)) print(combs) print(combs[2][0]) print(combs[2][1]) results in: [(1, 3), (1, 4), (2, 3), (2, 1), (2, 4), (3, 1), (3, 4)] 2 3 But there’s also a more elegant solution using list comprehensions: list1 … Read more