Slice a list of lists?

Jonno jonnojohnson at gmail.com
Wed Sep 8 20:55:50 CEST 2010


I know that I can index into a list of lists like this:
a=[[1,2,3],[4,5,6],[7,8,9]]
a[0][2]=3
a[2][0]=7

but when I try to use fancy indexing to select the first item in each
list I get:
a[0][:]=[1,2,3]
a[:][0]=[1,2,3]

Why is this and is there a way to select [1,4,7]?



More information about the Python-list mailing list