Answer to Question #231268 in Python for bhuvana

Question #231268

Given a MxN matrix,write a program to print all Anti-Diagonals elements of matrix


1
Expert's answer
2021-09-06T13:17:36-0400
M, N = map(int, input().split())

if M != N:
    print('Diagonal does not exist')
    exit()

matrix = []
for i in range(M):
    line = list(map(int, input().split()))
    matrix.append(line)
matrix = matrix[::-1]
anti_diagonal_elements = []
for i, el in enumerate(matrix):
    anti_diagonal_elements.append(el[i])
print('Answer:', *anti_diagonal_elements)

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