I need to input 2d array and make changes in it but the answer is always wrong. This is my code.
r,c,obs = map(int, input().split())
k = []
h = []
for i in range(r):
for j in range(c):
k.append(0)
h.append(k)
for i in range(r):
for j in range(c):
print(h[i][j],end=" ")
print()
while obs > 0:
l, k = map(int, input().split())
h[l-1][k-1] = 1
obs -= 1
for i in range(r):
for j in range(c):
print(h[i][j],end=" ")
print()
My input is this -
5 4 4
3 2
3 4
4 2
5 2
According to the code my resultant matrix should be something like this -
0 1 0 0
0 1 0 0
0 1 0 1
0 0 0 0
0 0 0 0
But it is always resulting to this -
0 1 0 1
0 1 0 1
0 1 0 1
0 1 0 1
0 1 0 1
Can anyone tell me what is wrong here??