[Tutor] dictionary question

Shi Mu samrobertsmith at gmail.com
Fri Nov 11 22:52:18 CET 2005


On 11/11/05, Eric Walker <ewalker at micron.com> wrote:
> All,
> I have a dictionary say:
> d = {'first':[]}
> I am going through another list and depending on whats going on,
> I want to add to the empty list. I have tried the following to noavail.
>
> d['first'] = d['first'].append("string")
>
> I would think this would result in the dictionary key first's empty list  to
> become ["string"].  can anyone help clear my head?
>
> Thanks...

I guess d['first'].append("string"), instead of, d['first'] =
d['first'].append("string")
or you will make d['first'] NoneType


More information about the Tutor mailing list