Question: in Python Problem 2 - Matrix Write a function diag_swap(M) that takes as input an nxn matrix M (which is a 2-dimensional list) and swaps

in Python Problem 2 - Matrix Write a function diag_swap(M) that takesin Python

Problem 2 - Matrix Write a function diag_swap(M) that takes as input an nxn matrix M (which is a 2-dimensional list) and swaps the values of the diagonal using ONE for loop. Note: You should not create a new list, the swapping should be done in the same list M. For example: print(diag_swap( [ [1,2,3,4], [5,6,7,8], [9, 10, 11, 12], [13,14,15,16) ])) # output [[16,2,3,13], [5,11,10,8], [9,7,6,12], [4,14,15,1]]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!