list of indices

Julien Ricard ujelin at yahoo.com
Mon Jul 24 11:14:35 EDT 2006


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 simpler way.

thanks in advance

Jul

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060724/244e287f/attachment.html>


More information about the Python-list mailing list