sub-list extraction, logical indexation

Pierre pierre.gaillard at gmail.com
Mon Aug 17 11:50:03 CEST 2009


Hello Everyone,

I would like to know if it is possible to extract a sub-list from a
list ?

typically if :

L =[[1, 2, 3],[4, 5, 6],[3] ]

How to extract easily the elements 0 and 2 of L in order to get :

L2 =[[1, 2, 3],[3] ]

Moreover, I would like to know if it is possible to use logical
indexation such that :

index = [ True, False, True]
L2 = L

or usual indexation, something like
index=[0, 2]
L2 = L

I tried, but failed...
Thanks for your help

Pierre



More information about the Python-list mailing list