2008/3/12, Gerdus van Zyl <[EMAIL PROTECTED]>:
>
> I have a list that looks like this:
> [['3'], ['9', '1'], ['5'], ['4'], ['2', '5', '8']]
>
> how can I get all the combinations thereof that looks like as follows:
> 3,9,5,4,2
> 3,1,5,4,2
> 3,9,5,4,5
> 3,1,5,4,5
> etc.
>
> Thank You,
> Gerdus
>
> --


list =  [['3'], ['9', '1'], ['5'], ['4'], ['2', '5', '8']]
newList = []
for l in list:
   newList.extend(l)

#newList = [3,9,1,5,4,2,5,8]
list=[]
for l in newList:
    if l not in list:
         list.append(l)

#now list is [3,9,1,5,4,2,8]

list.sort()

#now your list is in sorted order

Then, you can just write a series of for loops to spin off your data however
you like.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to