python mutate inner list end up mutating every inner list

后端 未结 0 1628
感动是毒
感动是毒 2020-12-21 09:09
>>> t = 3
>>> d = 1
>>> dp = [[0] * (t+1)] * (d+1)
>>> dp
[[0, 0, 0, 0], [0, 0, 0, 0]]
>>> dp[0][0] = 1
>>> dp
         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题