0

I have initialized a list of empty lists, like so:

>>> myList = [[]]*5
>>> myList
[[], [], [], [], []]

and I'm wanting to append one of those lists with something:

>>> myList[2].append(3)

but it appends 3 to all of my lists:

>>> myList
[[3], [3], [3], [3], [3]]

How can I append to just one of these lists?

Brad Flynn
  • 145
  • 8

0 Answers0