a=[[1],[2,3],[4,5,6]]
dp=[[0]*3]*3
dp[0][0]=a[0][0]
for i in range(1,3):
for j in range(0,len(a[i])):
if j==0:
dp[i][j]=dp[i-1][j]+a[i][j]
for i in range(3):
for j in range(3):
print(dp[i][j])
Output of the program: [[7,0,0],[7,0,0],[7,0,0]]
Expected output of the program: [[1,0,0],[3,0,0],[7,0,0]]
dp[i][j]=dp[i-1][j]+a[i][j] --> why the value is not getting assigned properly, the way I expect (expected output)
I tried to print the list dp but still I am not getting the output. I tried this in online compiler.