Write Function to Rotate the matrix by 180 degree


Topic: Write Function to Rotate the matrix by 180 degree

Solution

def rotateMatrix(mat): 
    N = 3  
    i = N - 1;  
    while(i >= 0): 
        j = N - 1; 
        while(j >= 0): 
            print(mat[i][j], end = " "); 
            j = j - 1; 
        print(); 
        i = i - 1; 
  
mat = [[1, 2, 3], 
       [ 4, 5, 6 ], 
       [ 7, 8, 9 ]]; 
rotateMatrix(mat); 



List all Python Programs