need a variation algorithm for Lists in Dictionaries

Marc Stuart marc.stuart.risney at gmail.com
Wed Jul 4 22:58:18 EDT 2007


Hi, I am trying to create a function, where I pass a dictionary with a
lits of strings, and try to return a
a list of strings, for all variations, any ideas ?
Thanks

def getAllVariants(someDict):
	keys = someDict.keys()
	for x in keys:
			print len(someDict[x])
			
			
x = {1:['a','b'],2:['b','c'],3:['d','e','f','g']}
getAllVariants(x)

""" I need to get a list of strings that render all possible variants,
this is what my output should be based on the
x dictionary:
abd
abe
abf
acd
ace
acf
acg
bbd
bbe
bbf
bcd
bce
bcf
bcg

"""



More information about the Python-list mailing list