How convert list to nested dictionary?
macm
moura.mario at gmail.com
Thu Nov 4 17:10:12 EDT 2010
Hi Chris
Thanks for your hint.
I am reading this
http://www.amk.ca/python/writing/functional
Do you have good links or books to me learn "Functional Programming"?
but I am not asking "...because is easy but because is hard."
Show me, please! if you can.
Thanks is advance.
Best regards
macm
On 4 nov, 16:53, Chris Rebert <c... at rebertia.com> wrote:
> On Thu, Nov 4, 2010 at 11:48 AM, macm <moura.ma... at gmail.com> wrote:
> > Hi Folks
>
> > How convert list to nested dictionary?
>
> >>>> l
> > ['k1', 'k2', 'k3', 'k4', 'k5']
> >>>> result
> > {'k1': {'k2': {'k3': {'k4': {'k5': {}}}}}}
>
> We don't do homework.
> Hint: Iterate through the list in reverse order, building up your
> result. Using reduce() is one option.
>
> Cheers,
> Chris
More information about the Python-list
mailing list