Re: [Tutor] Averaging a list of lists with a listcomp?

2007-04-26 Thread Andreas Kostyrka
* Terry Carroll <[EMAIL PROTECTED]> [070426 07:14]: > I have a list (of arbitrary length) of lists, each sublist having a fixed > number N of items, all integers. > > I would like to produce a list of N items, each item of which is an > integer which is the average of the elements in the same pos

Re: [Tutor] Averaging a list of lists with a listcomp?

2007-04-26 Thread Terry Carroll
On Thu, 26 Apr 2007, John Fouhy wrote: > So, here is your one-line solution: > > >>> [sum(x)/len(x) for x in zip(*orig)] > [30, 20, 50] Beautiful. Thanks. I wasn't looking for a one-liner, exactly, but just something that was more straightforward and pythonic than what I was doing. But I fin

Re: [Tutor] Averaging a list of lists with a listcomp?

2007-04-25 Thread John Fouhy
On 26/04/07, Terry Carroll <[EMAIL PROTECTED]> wrote: > I have a list (of arbitrary length) of lists, each sublist having a fixed > number N of items, all integers. > > I would like to produce a list of N items, each item of which is an > integer which is the average of the elements in the same pos

[Tutor] Averaging a list of lists with a listcomp?

2007-04-25 Thread Terry Carroll
I have a list (of arbitrary length) of lists, each sublist having a fixed number N of items, all integers. I would like to produce a list of N items, each item of which is an integer which is the average of the elements in the same position of each of the sublists of the original list. I realiz