I have the following code:
dp = [[False]*n]*n
for i in range(n):
dp[i][i] = True
But it will set all elements to true. For example, for n=2, I will get [[True, True], [True, True]] where I am expecting [[True, False], [False, True]]
Can anyone explain this?