How to print a specific column of a matrix in Python

1 Answer

0 votes
def print_column_of_matrix(matrix, col):
    rows = len(matrix)
    
    for i in range(rows):
        print(matrix[i][col], end=" ")
 
matrix = [
    [3, 2, 5, 1],
    [4, 7, 6, 5],
    [9, 3, 0, 1]
]
 
print_column_of_matrix(matrix, 1)

 
 
'''
run:
 
2 7 3 
 
'''

 



answered Jul 13, 2024 by avibootz
edited Jul 13, 2024 by avibootz
...