I have N number of lists (or sets), the number N which I do not know. I have to access one element from each list to check for a condition.
For eg, if
A = [1, 2, 3]
B = [5, 6]
c = [6, 7]
my combinations would be [(1,5,6), (1,5,7), (1,6,6), (1,6, 7), (2, 5, 6) and so on...]
How to do this efficiently?
list1 = [(i, j, k) for i in listx for j in listy for k in listz]
works for known N (here 3); How to do this for unknown N?