Python 3.6:
>>> x = [0, 1]
>>> y = [[]]*2
>>> z = dict(zip(x, y))
>>> z
{0: [], 1: []}
>>> z[0].append(0)
>>> z
{0: [0], 1: [0]}
>>>
Why did it append to both? I tried without zip and it worked fine. Please explain this behavior
Python 3.6:
>>> x = [0, 1]
>>> y = [[]]*2
>>> z = dict(zip(x, y))
>>> z
{0: [], 1: []}
>>> z[0].append(0)
>>> z
{0: [0], 1: [0]}
>>>
Why did it append to both? I tried without zip and it worked fine. Please explain this behavior