newbie/ merging lists of lists with items in common

Paddy paddy3118 at netscape.net
Fri Feb 2 23:23:48 EST 2007


On Feb 2, 10:34 pm, bearophileH... at lycos.com wrote:
> Paddy:
>
> >>> _ = [d[x0].append(x1) for x0,x1 in data]
Yep, definitely a case of overdoing the list comprehensions when you
throw away the list.
I'll watch out for that in the future,

Ta.

- Paddy.

>
> I think that you probably want:
>
> for text, num in data: d[text].append(num)
>
> ardief:
>
> > thanks to everyone for the help, and the speed of it! It's really
> > useful and I will spend some time working on understanding the code
> > you posted. I'd be so lost without this group...
>
> If you have Python 2.5, and if you don't have particular requirements,
> I think the best solution is Paddy's.
>
> Bye,
> bearophile





More information about the Python-list mailing list