I am new to programming and I have this basic problem I cannot fix. I simplified it as much as possible. In this simplified version, I am iterating through an empty list. I just want to store the indices in the "symmetric matrix":
n = 2
B = [[None] * n] * n
print B, "\n"
for i in range(n):
for j in range(n):
B[i][j] = [i, j]
print B
Initially, the list looks like this:
[[None, None], [None, None]]
After looping trough, I would expect the print-out to be:
[[[0, 0], None], [None, None]]
[[[0, 0], [0, 1]], [None, None]]
[[[1, 0], [0, 1]], [[1, 0], None]]
[[[1, 0], [1, 1]], [[1, 0], [1, 1]]]
Instead, I get this:
[[[0, 0], None], [[0, 0], None]]
[[[0, 0], [0, 1]], [[0, 0], [0, 1]]]
[[[1, 0], [0, 1]], [[1, 0], [0, 1]]]
[[[1, 0], [1, 1]], [[1, 0], [1, 1]]]
What am I missing? Thanks for helping out...