Re: List Splitting

2006-08-21 Thread Neil Cerutti
On 2006-08-21, Steven <[EMAIL PROTECTED]> wrote: > Hello everyone, > > I'm trying to work through a bit of a logic issue I'm having with a > script I'm writing. Essentially, I have a list that's returned to > me from another command that I need to regroup based on some aribitrary > length. > > For

Re: List Splitting

2006-08-21 Thread Brendon Towle
Not the most elegant solution, perhaps, but:>>>t = [ "a", "b", "c", "n", "a", "a", "t", "t", "t" ]>>>outlist = []>>>for x in range(3):...    temp=[]...    for y in range(len(t)/3):...        temp.append(t[3*y+x])...    outlist.append(temp)>>>outlist[['a', 'n', 't'], ['b', 'a', 't'], ['c', 'a', 't']

Re: List splitting

2006-08-21 Thread Steven
Klaus Alexander Seistrup wrote: > >>> t = [ "a", "b", "c", "n", "a", "a", "t", "t", "t" ] > >>> [t[i::3] for i in range(3)] > [['a', 'n', 't'], ['b', 'a', 't'], ['c', 'a', 't']] Klaus, Thanks for the fast reply! Had I taken the time to look at the list-type docs (which I did to understand how yo

Re: List Splitting

2006-08-21 Thread Bill Pursell
Steven wrote: > Hello everyone, > > I'm trying to work through a bit of a logic issue I'm having with a > script I'm writing. Essentially, I have a list that's returned to > me from another command that I need to regroup based on some aribitrary > length. > > For the purposes of this question, the

Re: List Splitting

2006-08-21 Thread Tim Chase
> For the purposes of this question, the list will be: > > t = [ "a", "b", "c", "n", "a", "a", "t", "t", "t" ] > > Now, I know that every 3rd element of the list belongs together: > > Group 1 = 0, 3, 6 > Group 2 = 1, 4, 7 > Group 3 = 2, 5, 8 > > I'm trying to sort this list out so that I get a

Re: List splitting

2006-08-21 Thread Klaus Alexander Seistrup
Steven skrev: > For the purposes of this question, the list will be: > > t = [ "a", "b", "c", "n", "a", "a", "t", "t", "t" ] > > Now, I know that every 3rd element of the list belongs together: > > Group 1 = 0, 3, 6 > Group 2 = 1, 4, 7 > Group 3 = 2, 5, 8 > > I'm trying to sort this list out so th

List Splitting

2006-08-21 Thread Steven
Hello everyone, I'm trying to work through a bit of a logic issue I'm having with a script I'm writing. Essentially, I have a list that's returned to me from another command that I need to regroup based on some aribitrary length. For the purposes of this question, the list will be: t = [ "a", "b