Here is a simple and easy to understand answer along the lines of what you were trying to do in the beginning:
def negativesToZero(A):
index = 0 #Track your index
for x in A:
if isinstance(x, list): #Calling the program recursively on nested lists
A[index] = negativesToZero(x)
elif x < 0:
A[index] = 0 #Makes negatives 0
else:
pass #Ignores zeros and positives
index += 1 #Move on to next index
print A
return A
If you don't want the unwanted inner print statements you can add an input variable (I will call it 'recur') to the function that makes only the non recursive call print:
def negativesToZero(A, recur = False):
index = 0
for x in A:
if isinstance(x, list):
A[index] = negativesToZero(x, True)
elif x < 0:
A[index] = 0
else:
pass
index += 1
if recur == False: print A
return A
Result:
A = ([[1,-2],\
[-2,1],\
[-5, -6], [4,7]])
negativesToZero(A)
>>>> [[1, 0], [0, 1], [0, 0], [4, 7]]