[Tutor] help with list permutations

c t bertha.rambler at gmail.com
Thu Jan 3 20:06:51 CET 2008

Greeting from a real newbie,

I think that their might exist an easy way, in Python, for my list
permutation issue. I need to be able to permute all elements from across
several lists, while ensuring order is maintained across the lists.

For example: list1=[a b]   list2=[c d e]  list3=[f]  list4=[g h]

permute(list1, list2, list3, list4) =

[ [a c f g], [a c f h], [a d f g], [a d f h], [a e f g], [a e f h],
  [b c f g], [b c f h], [b d f g], [b d f h], [b e f g], [b e f h] ]

Of course, the number of the lists is arbitrary and the size of each list is
also arbitrary.

Any help would be greatly appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080103/7ea660f4/attachment.htm 

More information about the Tutor mailing list