I'm writing a simple code in Python to sort a pre existing array A of dimensions [6][7] to do that I wanted to save the sorted array with a different name let's say B. I've done the following code but doesn't work
B=[[0]*7]*6
For i in range(0,6):
For j in range(0,7):
If A[i][j] > 7:
B[i][j] = 1
Else
B[i][j] = 0
The problem is in the preallocation of array B indeed if I print it it doesn't give the result I need, on the other hand if create B from scratch in a way like this it works
B=[
[0,0,0,0,0,0,0],
.
.
.
.
.
.
]
Can someone explain me why? Thank you very much.