Indexing list of lists

John J. Lee jjl at pobox.com
Tue Sep 16 15:04:25 EDT 2003


hildegarde_roth at yahoo.de (Hilde Roth) writes:

> This may have been asked before but I can't find it. If I have
> a rectangular list of lists, say, l = [[1,10],[2,20],[3,30]], is 
> there a handy syntax for retrieving the ith item of every sublist?
> I know about [i[0] for i in l] but I was hoping for something more
> like l[;0].

If you need that kind of thing a lot, look at Numeric (or its
replacement, numarray), or perhaps the standard library's array
module.


John




More information about the Python-list mailing list