Thanks Kent, I liked the generator solution (I knew there had to be
something like that).
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Kent Johnson
Sent: 09 May 2006 17:54
Cc: tutor@python.org
Subject: Re: [Tutor] Summing part of a list
<<
2 passes of the original list).
Surely there is a neater way.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Matthew Webber
Sent: 09 May 2006 17:22
To: tutor@python.org
Subject: [Tutor] Summing part of a list
I have a list that looks a bit like this -
Matthew Webber wrote:
> I have a list that looks a bit like this -
>
> [(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299),
> (u'fin', 6), (u'ven', 6), (u'chi', 3), (u'hun', 3), (u'mar', 3),
> (u'lux', 2), (u'smo', 2), (u'tch', 2), (u'aho', 1), (u'ber', 1)]
>
> The list items are tuples
Matthew Webber wrote:
> I have a list that looks a bit like this -
>
> [(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299),
> (u'fin', 6), (u'ven', 6), (u'chi', 3), (u'hun', 3), (u'mar', 3),
> (u'lux', 2), (u'smo', 2), (u'tch', 2), (u'aho', 1), (u'ber', 1)]
>
> The list items are tuple
I have a list that looks a bit like this -
[(u'gbr', 30505), (u'fra', 476), (u'ita', 364), (u'ger', 299),
(u'fin', 6), (u'ven', 6), (u'chi', 3), (u'hun', 3), (u'mar', 3),
(u'lux', 2), (u'smo', 2), (u'tch', 2), (u'aho', 1), (u'ber', 1)]
The list items are tuples, the first item of which is a coun