Why it doesn't work?
Martin P. Hellwig
mhellwig at xs4all.nl
Mon Jan 9 03:51:38 EST 2006
Lad wrote:
> I have a list
> L={}
> Now I can assign the value
> L['a']=1
> and I have
> L={'a': 1}
>
> but I would like to have a dictionary like this
> L={'a': {'b':2}}
>
> so I would expect I can do
> L['a']['b']=2
>
> but it does not work. Why?
>
> Thank you for reply
> Rg,
> L.
>
Hi,
Perhaps what you try to do is something different than what I did here
but it works for me:
>>> D={'a':{'b':''}}
>>> D['a']['b']=2
>>> D
{'a': {'b': 2}}
--
mph
More information about the Python-list
mailing list