Answer the question
In order to leave comments, you need to log in
How to get all permutations of array elements?
The essence of the problem is as follows:
there is an array .
arr = [a,b,c,d]
I need to iterate (change) it so that I get all the options for the arrangement of elements,
#a,b,c,d
#a,b,d,c
#a,c,b,d
#a,c ,d,b
etc.
Answer the question
In order to leave comments, you need to log in
import itertools
for variant in itertools.permutations([a, b, c, d]):
print(variant)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question