a = [[1,2,3],[4,5,6],[7,8,9]]
for x in a:
x[0] = 0
print(a)
gives:
[[0, 2, 3], [0, 5, 6], [0, 8, 9]]
but:
for x in a:
for y in x:
y = 0
gives:
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
I expected:
[[0,0,0],[0,0,0],[0,0,0]]
Why couldn't I modify 'a' in the second example?