I wrote a function as follows:
def change_value(array):
for i in range(len(array)):
for j in range(len(array[i])):
if array[i][j]==0:
array[i][j],array[0][0]= array[0][0],array[i][j]
print(array[i][j],end=' ')
print()
array=[[1,2,3],[4,0,6],[7,8,5]]
change_value(array)
This function exchanges the values of the two desired indices after receiving the array. But the output was as follows:
1 2 3
4 1 6
7 8 5
What is the solution to this problem?