Quoting Chuck Allison <[EMAIL PROTECTED]>:

> Hello Tutors,
> 
> What would be the most Pythonic way of printing (or extracting) every 
> other element of a list? Thanks in advance.

This is probably it:

>>> arr = range(20)
>>> arr[::2]
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
>>> arr[1::2]
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19]

-- 
John.
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to