>>indices=[0,3,6]
>>new_list=list[indices]
> new_list = [list[x] for x in indicies]
and just as a caveat, it's generally considered bad form to
shadow the built-in list as such...
-tkc
--
http://mail.python.org/mailman/listinfo/python-list
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
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]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 si