On dynamic creation of 2D array in Python3, values are not being updated in the following case:
no_col = 3
no_row = 4
arr = [[0 for x in range(no_col)] for y in range(no_row)]
for i in arr[0]:
i = 1
arr values
0 0 0
0 0 0
0 0 0
0 0 0
But on using range, values get updated
for i in range(no_col):
arr[0][i] = 1
arr values
1 1 1
0 0 0
0 0 0
0 0 0
Why this happens ?