I am totally new to programming, and I have written this function function to take a matrix and maps each nonzero element to its inverse and zero to zero in python. Here is my code:
def question_1_c(arr):
new_arr = []
for i in range(len(arr)):
row_arr = []
for j in range(len(arr[i])):
row_arr.append(1/ arr[i][j])
new_arr.append(row_arr)
return new_arr
question_1_c([[70,0,13,67],[90,48,57,26],[43,45,67,89],[88,65,44,23]])
For some reason it gives an error. Can anyone help?