Why it doesn't work?
Tomasz Lisowski
list at notmyisp.pl
Mon Jan 9 04:18:08 EST 2006
Lad wrote:
> I have a list
> L={}
This IS a dictionary, not a list.
> 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}}
You need to initialise L['a'] first, before referencing L['a']['b']
So, you need to call first:
L['a'] = {}
Then you can write:
L['a']['b'] = 2
Tomasz Lisowski
More information about the Python-list
mailing list