Write a program to find the sum of diagonal elements in a matrix.
a = [[11,2,4],[4,5,6],[10,8,-12]]
sum_second_diagonal=sum([a[i][j] for i in range(n) for j in range(n) if i+j==n-1])
Comprehensions provide a concise way to create new set of elements that satisfy a given condition from an iterable. Here the iterable is the for loop looking for diagonal elements. The list thus formed is passed to sum which returns the sum of elements in the list.