newbie/ merging lists of lists with items in common

ardief rachele.defelice at gmail.com
Fri Feb 2 10:17:13 EST 2007


On Feb 2, 1:55 pm, "ardief" <rachele.defel... at gmail.com> wrote:
> Hi everyone
> Here is my problem:
> I have a list that looks like this -
> [['a', '13'], ['a', '3'], ['b', '6'], ['c', '12'], ['c', '15'], ['c',
> '4'], ['d', '2'], ['e', '11'], ['e', '5'], ['e', '16'], ['e', '7']]
>
> and I would like to end up with something like this, i.e. with the
> only one list per letter:
>
> [['a', ['13' '3']], ['b', '6'], ['c', ['12', '15', '4']], ['d', '2'],
> ['e', ['11', '5', '16', '7']]]
....

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...

r




More information about the Python-list mailing list