P
Peter Kleiweg
This does not what I want it to do:
This does what I want:
The first is clear and wrong. The second is hairy and right.
Is there a way to do it clear and right?
[['X'], ['X'], ['X'], ['X'], ['X'], ['X']]>>> a = [[]] * 6
>>> a[3].append('X')
>>> a
This does what I want:
[[], [], [], ['X'], [], []]>>> b = [[] for _ in range(6)]
>>> b[3].append('X')
>>> b
The first is clear and wrong. The second is hairy and right.
Is there a way to do it clear and right?