1

I ran into some troubles when creating a list of 3 lists. Here is the code:

>>> li = [[]]*3
>>> li
[[], [], []]
>>> li[0].append(1)
>>> li
[[1], [1], [1]]

Why is the result not [[1], [], []]?

Taku
  • 31,927
  • 11
  • 74
  • 85
Tao
  • 17
  • 2

0 Answers0