list behavior

Rene Aguirre reneaguirre at yahoo.com
Mon Oct 27 13:11:46 EST 2003


Hello everybody,

I needed to add a list to a dictionary, something very simple:
>>> d = {}
>>> l = []
>>> l.append(1)
>>> d["one"] = l
>>> d
{'one': [1]}

Buen, when I just move the 'append' statement to the dictionary
assigment then:
>>> l = []
>>> d = {}
>>> d["one"] = l.append(1)
>>> d
{'one': None}

Not what I expected, then I came to the conclusion that
[].append(value) returns 'None', why?

Rene A.




More information about the Python-list mailing list