0

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.

1 Answer 1

3

Use itertools.product:

from itertools import product
l = [[0, 3], [1, 4], [2]]

for prod in product(*l):
    print(prod)
Sign up to request clarification or add additional context in comments.

4 Comments

@BhargavRao, i prefer the blue highlighting ;)
Hey, don't you like blue on grey?
Lol... BTW, your statements are contradictory i prefer the blue highlighting and I am colour blind :P
@BhargavRao, there you go, you should never listen to a guy who is colourblind talking about colour ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.