T
tkpmep
I want to create a list of lists, each of which is identical, but which
can be modified independently i.e:
The above construct works if I have only few items, but if I have many,
I'd prefer to write
If I now try extending the lists indepently, I cannot, as they all
point to the same list object
Is there a simple way to create a list of independent lists?
Thanks in advance
Thomas Philips
can be modified independently i.e:
[[0, 1], [0], [0]]x = [ [0], [0], [0] ]
x[0].append(1)
x
The above construct works if I have only few items, but if I have many,
I'd prefer to write
[[0], [0], [0]]N =3
x =N*[[0]]
x
If I now try extending the lists indepently, I cannot, as they all
point to the same list object
[[0, 1], [0, 1], [0, 1]]x[0].append(1)
x
Is there a simple way to create a list of independent lists?
Thanks in advance
Thomas Philips