Append to list of lists
Posted
by Joel
on Stack Overflow
See other posts from Stack Overflow
or by Joel
Published on 2010-03-27T11:47:57Z
Indexed on
2010/03/27
11:53 UTC
Read the original article
Hit count: 256
python
Hello,
I am trying to build a list of lists using the following code:
list=3*[[]]
Now I am trying to append a string to the list in position 0:
list[0].append("hello")
However, instead of receiving the list
[ ["hello"] , [], [] ]
I am receiving the list:
[ ["hello"] ,["hello"] , ["hello"] ]
Am I missing something?
Thanks,
Joel
© Stack Overflow or respective owner