list behavior

R

Rene Aguirre

A

anton muhin

Rene said:
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.

append is what is called procedure in other languages.

d["one"].append(1) should work

hth,
anton.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,458
Latest member
Chris#

Latest Threads

Top