[Tutor] Accessing Values of specific column in a 2D list or array

Ricardo Aráoz ricaraoz at gmail.com
Sun Sep 2 19:52:50 CEST 2007

Varsha Purohit wrote:
> Thanks Eric and Alan i did that with while loop. I donno i was getting
> an error while using a for loop for subindexing. Here is what i did
> i=0
> selectCols=0
> arr2=[]
> while i<rows:
>     selectCols=grid[i][colID]
>     i+=1
>     arr2.append(selectCols)
> print "col",colID,"values :",arr2

How about :

print 'Col', colID, 'values :', ', '.join([str(i[colID]) for i in grid])

More information about the Tutor mailing list