hii

I have a list having m1 m2 m3........ m922

and in each there are a1 a2 a3 a4 are there like
m1=a1 a2 a3 a4 a5 a6
m2=a1 a2 a3 a4 a5 a6
m3=a1 a3 a5 a7 a8 a2

etc

and i want this as

m1=a1 a2 a3 a4 a5 a6
a2 a3 a4 a5 a6 a1
a3 a1 a2 a4 a5 a6
a4 a1 a2 a3 a5 a6
m2 =a1 a2 a3 a4 a5 a6
a2 a3 a4 a5 a6 a1
a3 a1 a2 a4 a5 a6
a4 a1 a2 a3 a5 a6

Combinations, permutations etc can be found in itertools module.

## All 4 Replies

It is very difficult to understand how the expected output is connected to the input. Can you explain this ? Also why did you post this in four different forums (python, java, C, C++)? What do you want exactly ?

i just wanted it to be done bro...... i am not good with programming and output is just all possible combinations of input

Combinations, permutations etc can be found in itertools module.

For example:

``````import itertools

s = "a1 a2 a3 a4 a5 a6"
seq = s.split()
print(seq)  # test

for e in itertools.permutations(seq):
print(" ".join(e))
``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.