I am trying to loop through my list of lists, and change the values. I want this to print [['1','2'],['3','4']]. but it prints [['3','4'],['3','4']]. Can anyone please explain why this is happening? When I put a print statement, count increase for each iterations.
edit: it works if I manually create a list like [[0,0],[0,0]]. So what is the [[0]*2]*2 doing differently? They both look like 2d lists.
class Sudoku:
def __init__(self):
self.board=[[0]*2]*2
s=Sudoku()
count=1
for i in range(2):
for j in range(2):
s.board[i][j]=count
count+=1
print(s.board)