12/14/2017

arrays - How to access a column(or row) in a list of lists in python

OK, we have like that list:

ListOfList = [ ['abcd',1], ['efgh',2], ['ijkl',3]]
print(ListOfList)



Let access list in list.
print('row 0', [row[0] for row in ListOfList] )
print('row 1', [row[1] for row in ListOfList] )




Very easy isn't it?
Enjoy~!


No comments:

Post a Comment