Python ProgrammingPython Programming

How to generate permutations between two lists of unequal length in Python?

Example-1

import itertools


list1 = ['A', 'B', 'C']
list2 = [1, 2]

permutations = [list(zip(x, list2)) for x in itertools.permutations(list1, len(list2))]
print(permutations)
[[('a', 1), ('b', 2)], [('a', 1), ('c', 2)], [('b', 1), ('a', 2)], [('b', 1), ('c', 2)], [('c', 1), ('a', 2)], [('c', 1), ('b', 2)]]