a=int(input())
d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
e=[c,c,c,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d]
for i in range(a):
b , c=input().split(' ')
b=int(b)
print(b)
c=int(c)
print(c)
e[b-1][c-1]=1
print(e)
This is the code, so if you enter the position where you put the white stone on the checkerboard 19*19, ex.
2
4 6
5 9
It's a code that says you'll put two white go eggs and put them at (4,6) (5,9) when you go and hit it's a code
The problem is that e[b-1][c-1]=1
is acting strangely.
e[b-1][c-1]
If it's just one location, the entire line changes.
What did you do wrong?
import print
a=int(input())
e = [[0 for col in range(10)] for row in range(10)]
for i in range(a):
b , c=input().split(' ')
b=int(b)
c=int(c)
print(b, c)
e[b-1][c-1]=1
pprint.pprint(e)
1
4 6
4 6
[[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]
I don't know the exact reason, but when it comes to initializing the arrangement, In the same or similar case as below, if you modify the specific value afterwards, it all changes collectively.
e = [[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]* 10
© 2025 OneMinuteCode. All rights reserved.