S
Steven Bethard
I feel like this has probably been answered before, but I couldn't
find something quite like it in the archives. Feel free to point me
somewhere if you know where this has already been answered.
I have a list in a particular order that I want to split into two
lists: the list of every nth item, and the list of remaining items.
It's important to maintain the original order in both lists.
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?
Steve
find something quite like it in the archives. Feel free to point me
somewhere if you know where this has already been answered.
I have a list in a particular order that I want to split into two
lists: the list of every nth item, and the list of remaining items.
It's important to maintain the original order in both lists.
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?
Steve