Am 13.08.2016 um 03:08 schrieb Steven D'Aprano:
On Sat, 13 Aug 2016 06:44 am, Mok-Kong Shen wrote:

list2 = [1,2,3]
list1 += [4,5,6]
print(list1, list2)
[1, 2, 3, 4, 5, 6] [1, 2, 3]


Does that help?

I don't yet understand why in my 2nd example list2 came out as
[1, 2, 3] outside.

Because you assign list2 = [1, 2, 3]. What did you expect it to be?

But in my function test() there is a code line "list2=list2+[4,5,6]".
Could you kindly explain why this didn't work?

M. K. Shen

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to