All problems
Matrix Column Extraction
Problem
Extract column j from a matrix A as a list.
A is given as a list of rows, so return [A[0][j], A[1][j], ...] with one entry per row.
Hint
Index the same position in every row.
Test cases
case 1
in: [[[1,2],[3,4]],1]
expected: [2,4]
case 2
in: [[[1,2],[3,4]],0]
expected: [1,3]
case 3
in: [[[5,6,7]],2]
expected: [7]
case 4
in: [[[1],[2]],0]
expected: [1,2]
case 5
in: [[[0.5,-1.5],[2.5,3.5]],1]
expected: [-1.5,3.5]
Starter codePython
def matrix_column(A, j):
# Your code here
pass5 test cases · run your code against them in the editor