Write a program to print the anti-diagonal elements in the given matrix.
# matrix
matrix = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
n=3
# display the anti-diagonal elements in the given matrix
print("The anti-diagonal elements in the given matrix:")
for i in range(n):
for j in range(n):
if ((i + j) == (n - 1)):
print(matrix[i][j], end = " ")
print()
Comments
Leave a comment