[Baypiggies] nested list to dict question
Fred C
fred at kas-group.com
Tue Dec 28 17:06:29 CET 2010
y = {}
for k, v in x:
y.setdefault(k, []).append(v)
On Dec 28, 2010, at 7:51 AM, Vikram K wrote:
> I have a nested list which looks something like this:
>
> x = [['104', '4501919'], ['104', '237681091'], ['104', '7669477'], ['100528064', '315259111']]
>
> I wish to convert this to a dict type which looks something like this:
>
> y = {'104': ['4501919', '237681091', '7669477'], '100528064': ['315259111']}
>
> Please help!
>
> Thanks
> Vikram
>
>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies
--
Writing Java code is like using a sledgehammer to hang a picture frame.
Fred C.
fred at bsdhost.net
http://kiq.me/JP
More information about the Baypiggies
mailing list