about list

Adonis adonisv at DELETETHISTEXTearthlink.net
Mon Nov 21 02:34:55 CET 2005


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 helps.

Adonis



More information about the Python-list mailing list