LISTS: Extract every other element

Fredrik Lundh fredrik at pythonware.com
Fri Dec 17 07:03:54 EST 1999


Randall Hopper <aa8vb at yahoo.com> wrote:
> I want to take a large list:
> 
>   [ 1,2,3,4,5,6,7,... ]
> 
> and build a list with every other element:
> 
>   [ 1,3,5,7,... ]

footnote:

a = b[::2] should work, but it doesn't.

see
http://www.python.org/doc/current/ref/slicings.html
for further details.

maybe in 1.6?

</F>





More information about the Python-list mailing list