0

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?

user3086871
  • 671
  • 3
  • 7
  • 25

0 Answers0