Hello everybody,
I needed to add a list to a dictionary, something very simple:[color=blue][color=green][color=darkred]
>>> d = {}
>>> l = []
>>> l.append(1)
>>> d["one"] = l
>>> d[/color][/color][/color]
{'one': [1]}
Buen, when I just move the 'append' statement to the dictionary
assigment then:[color=blue][color=green][color=darkred]
>>> l = []
>>> d = {}
>>> d["one"] = l.append(1)
>>> d[/color][/color][/color]
{'one': None}
Not what I expected, then I came to the conclusion that
[].append(value) returns 'None', why?
Rene A.
I needed to add a list to a dictionary, something very simple:[color=blue][color=green][color=darkred]
>>> d = {}
>>> l = []
>>> l.append(1)
>>> d["one"] = l
>>> d[/color][/color][/color]
{'one': [1]}
Buen, when I just move the 'append' statement to the dictionary
assigment then:[color=blue][color=green][color=darkred]
>>> l = []
>>> d = {}
>>> d["one"] = l.append(1)
>>> d[/color][/color][/color]
{'one': None}
Not what I expected, then I came to the conclusion that
[].append(value) returns 'None', why?
Rene A.
Comment