Answer to Question #310874 in Python for Fe 3

Question #310874

Elements of anti diagonal



Input


3


123


456


789

1
Expert's answer
2022-03-17T13:56:14-0400
def read_matrix():
    n = int(input())


    M = []
    for i in range(n):
        line = input()
        row = [int(s) for s in line.split()]
        M.append(row)

    return M


def antidiagonal(M):
    n = len(M)
    L = []
    for i in range(n):
        x = M[i][n-1-i]
        L.append(x)
    return L


def main():
    M = read_matrix()
    D = antidiagonal(M)
    for x in D:
        print(x, end=' ')
 

main()

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