Why can the list comprehension select the columns of a matrix? I am a bit confused by the for-loop.
m = [[1,2,3],[4,5,6],[7,8,9]]
col = [x for x in m]
col2 = col[1]
print col2 # [4, 5, 6]
Obviously the below codes give the right answer, but why is that? Because in each iteration, the for-loop takes in a whole row instead of a number?
m = [[1,2,3],[4,5,6],[7,8,9]]
col2 = [x[1] for x in m]
print col2 # [[2, 5, 8]]