Reputation: 176
I have this array:
[[0, 3], [1, 4], [2]]
i want to display all possible combinations of the array,for example:
0 1 2
3 1 2
0 4 2
3 4 2
the row and the columns of this array is not constant.it changes by the input of the user.
Upvotes: 0
Views: 365
Reputation: 180471
Use itertools.product:
from itertools import product
l = [[0, 3], [1, 4], [2]]
for prod in product(*l):
print(prod)
Upvotes: 3