Slice a list of lists?
tjreedy at udel.edu
Wed Sep 8 22:27:02 CEST 2010
On 9/8/2010 2:55 PM, Jonno wrote:
> I know that I can index into a list of lists like this:
> but when I try to use fancy indexing to select the first item in each
> list I get:
> Why is this and is there a way to select [1,4,7]?
You are trying to look at a list of lists as an array and have
discovered where the asymmetry of the former makes the two
non-equivalent. To slice multi-dimensional arrays any which way, you
need an appropriate package, such as numpy.
Terry Jan Reedy
More information about the Python-list