Best way for permutating using multiple lists?

Jon Clements joncle at
Fri Nov 6 14:39:44 CET 2009

On Nov 6, 1:32 pm, hob <cokofree... at> wrote:
> if __name__ == '__main__':
>     permutations = list()
>     for i in list('def'):
>         for j in list('abc'):
>             for k in list('mno'):
>                 for l in list('mno'):
>                     for m in list('wxyz'):
>                         permutations.append()
>     print '\t'.join("%s" % i for i in permutations)
> I'd rather find a way that can perform a permutation over any number
> of lists. I know there should be a way of doing this but my head isn't
> working today, any advice people?

itertools.permutations (maybe with itertools.chain)?


More information about the Python-list mailing list