0

I'm using the code below to find the permutations.

from itertools import permutations  
seq = permutations(['1','2','3'])  
print(seq)  
for p in list(seq):  
print(p)  

Output:

('1', '2', '3')
('1', '3', '2')
('2', '1', '3')
('2', '3', '1')
('3', '1', '2')
('3', '2', '1')

How can I let python automatically assign a variable for each permutation as shown below ?

p1=('1', '2', '3')
p2=('1', '3', '2')
p3=('2', '1', '3')
p4=('2', '3', '1')
p5=('3', '1', '2')
p6=('3', '2', '1')

I am not sure what to do to make it automatically assign variables for the permutation. because I am trying to use these variables in the next step.

quamrana
  • 37,849
  • 12
  • 53
  • 71

0 Answers0