This does not what I want it to do:
[color=blue][color=green][color=darkred]
>>> a = [[]] * 6
>>> a[3].append('X')
>>> a[/color][/color][/color]
[['X'], ['X'], ['X'], ['X'], ['X'], ['X']]
This does what I want:
[color=blue][color=green][color=darkred]
>>> b = [[] for _ in range(6)]
>>> b[3].append('X')
>>> b[/color][/color][/color]
[[], [], [], ['X'], [], []]
The first is clear and wrong. The second is hairy and right.
Is there a way to do it clear and right?
--
Peter Kleiweg L:NL,af,da,de,e n,ia,nds,no,sv, (fr,it) S:NL,de,en,(da, ia)
info: http://www.let.rug.nl/~kleiweg/ls.html
Comment