# itertools — Functions creating iterators for efficient looping # See : https://docs.python.org/3/library/itertools.html import itertools x = [A,1,B,2] l = list(itertools.combinations(x, 2)) print(l) [(A, 1), (A, B), (A, 2), (1, B), (1, 2), (B, 2)]