Exclude every nth element from list?

Bob Gailer bgailer at gmail.com
Sat Mar 26 13:03:17 EDT 2016


On Mar 26, 2016 12:50 PM, "beliavsky--- via Python-list" <
python-list at python.org> wrote:
>
> I can use x[::n] to select every nth element of a list. Is there a
one-liner to get a list that excludes every nth element?

[y for (i,y) in enumerate(x) if i % n]



More information about the Python-list mailing list