Re: about list

2005-11-20 Thread Jeffrey Schwab
[EMAIL PROTECTED] wrote: > 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/Reci

Re: about list

2005-11-20 Thread rurpy
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

Re: about list

2005-11-20 Thread Adonis
Shi Mu wrote: > How to run a function to make [1,2,4] become [[1,2],1,4],[2,4]]? > Thanks! From what I gather try: a = [1,2,4] n = list() for i in a: index = a.index(i) + 1 for x in a[index:]: n.append([i, x]) print n more elegant ways to do this, but its a start. hope this h

Re: about list

2005-11-20 Thread [EMAIL PROTECTED]
try to describe what you want as it is not very obvious, and has syntax error. Shi Mu wrote: > How to run a function to make [1,2,4] become [[1,2],1,4],[2,4]]? > Thanks! -- http://mail.python.org/mailman/listinfo/python-list