0

I don't understand following behavior of lists assignment with tuple. I'm probably missing something evident...

Following code:

a, b = 1, 2
print(a, b)

produces that output:

1 2

as expected. However, following code:

list0, list1 = ([None] * 1, ) * 2
list0[0], list1[0] = 0, 1
print(list0)
print(list1)

has following output:

[1]
[1]

while I would expect

[0]
[1]

What am I missing? I'm using Python 3.7.

0 Answers0