I'm new to python, and I'm having trouble with certain aspects of the language. Right now I'm trying to create a 3 dimensional table that can hold certain values.
table[x][y][z]
X and Y are both initialized to have the same number of elements, and z is initialized to be an empty list like so
table = [[[]]*length]*length
so that a table of length 3 would look like-
[[[],[],[]] , [[],[],[]] , [[],[],[]]]
At certain values of x, y I would like to be able to append a singular z list like this
table[0][2].append('S')
would cause the table to look like
[[[],[],['S']] , [[],[],[]] , [[],[],[]]]
but it's coming out like this
[[['S'],['S'],['S']] , [['S'],['S'],['S']] , [['S'],['S'],['S']]]
so that every z list is appended. Why is this happening and how can i fix it. I can work around this inefficiently but I don't want to.