spliting a list by nth items
Ed Leafe
ed at leafe.com
Thu Sep 23 16:59:33 EDT 2004
On Sep 23, 2004, at 1:25 PM, Steven Bethard wrote:
> So the first list is simple:
>
> nth_items = items[::n]
>
> The second list is what's giving me trouble. So far, the best I've
> come up with is:
>
> non_nth_items = list(items)
> del non_nth_items[::n]
>
> Is this the right way to do this?
nth_items = items[::n]
non_nth_items = [item for item in items if not in nth_items]
___/
/
__/
/
____/
Ed Leafe
http://leafe.com/
http://dabodev.com/
More information about the Python-list
mailing list