list of indices

Chris Lambacher chris at kateandchris.net
Mon Jul 24 11:24:46 EDT 2006


On Mon, Jul 24, 2006 at 08:14:35AM -0700, Julien Ricard wrote:
>    hi,
> 
>    is there any method to get only some elements of a list from a list of
>    indices. Something like:
> 
>    indices=[0,3,6]
>    new_list=list[indices]
    new_list = [list[x] for x in indicies]
> 
>    which would create a new list containing 0th, 3rd and 6th elements from
>    the original list? I do this with a loop but I'd like to know if there is
>    a simpler way.
> 
>    thanks in advance
> 
>    Jul

> -- 
> http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list