Best way for permutating using multiple lists?

hob cokofreedom at
Fri Nov 6 14:32:58 CET 2009

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'):
    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?

More information about the Python-list mailing list