subset permutations

Rick Wotnaz desparn at
Fri Dec 9 04:40:56 CET 2005

Jay Parlar <jparlar at> wrote in 
news:mailman.1878.1134095737.18701.python-list at


A string is also iterable, so whether s is the string (as shown) or 
list('ACDEFGHIKLMNPQRSTVWY'), as you have it above, this should 
generate the 160000 permutations, as a list of 4-character strings.

x = ['%s%s%s%s' % (v,w,x,y) for v in s 
    	for w in s for x in s for y in s]


More information about the Python-list mailing list