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
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']
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
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
> 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
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
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