Example:
a = [[1,2,3],[4,5,6],[7,8,9]]
By doing something like a[:][0]
, I expect it to give me 1st elements in each row [1,4,7]
However, I get [1,2,3]
. I can always make a function to do it.
def column(array,index):
result = []
for row in array:
result.append(row[index])
return result
But I was wondering: is there a smarter way of doing it?