Answer to Question #174682 in Python for bhuvanesh

Question #174682

Write a program to print the anti-diagonal elements in the given matrix.


1
Expert's answer
2021-03-25T23:35:46-0400
# 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()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS