On Jul 5, 3:58 am, "Marc Stuart" <[EMAIL PROTECTED]> wrote: > 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 > > """
Here's two possibilities: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/502199 http://jace.seacrow.com/archive/2007/02/15/generating-combinations-in-python - Paddy. -- http://mail.python.org/mailman/listinfo/python-list