Most of my test cases are returning correct results but one this one is returning True when it should be false:
print antisymmetric([[0, 1, 2],
[-1, 0, -2],
[2, 2, 3]])
Can anyone tell me what's wrong with my code? Thanks!
def antisymmetric(A):
n = len(A)
i = 0
while i < n:
j = 0
while j < n:
if A[i][j] == -A[j][i]:
return True
else:
return False
j += 1
i += 1
# Test Cases:
print antisymmetric([[0, 1, 2],
[-1, 0, 3],
[-2, -3, 0]])
#>>> True
print antisymmetric([[0, 0, 0],
[0, 0, 0],
[0, 0, 0]])
#>>> True
print antisymmetric([[0, 1, 2],
[-1, 0, -2],
[2, 2, 3]])
#>>> False
print antisymmetric([[1, 2, 5],
[0, 1, -9],
[0, 0, 1]])
#>>> False