1prim =0
2 sec=0
3 length = len(arr[0])
4 for count in range(length):
5 prim += arr[count][count]
6 sec += arr[count][(length-count-1)]
7 return abs(prim-sec)
8
1def diagonalDifference(arr):
2 # Write your code here
3 d1 =0
4 d2=0
5 for i in range(len(arr[0])):
6 d1 += arr[i][i]
7 d2 += arr[i][(len(arr[0])-i-1)]
8 return abs(d1-d2)
1def diagonalDifference(arr):
2 # Write your code here
3 d1 = sum([arr[x][x] for x in range(len(arr))])
4 d2 = sum([arr[x][n - 1 - x] for x in range(len(arr))])
5 return(abs(d1 - d2))