Shi Mu wrote: > How to run a function to make [1,2,4] become [[1,2],1,4],[2,4]]? > Thanks!
You want [[1,2],[1,4],[2,4]]? That is, all combinations of 2 items from the list? You might want to look at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/190465 >>> import * from xpermutations >>> [x for x in UniqueCombinations ([1,2,4], 2)] [[1, 2], [1, 4], [2, 4]] That web page also gives urls to other recipies that do the same thing. -- http://mail.python.org/mailman/listinfo/python-list