Exclude every nth element from list?

Erik python at lucidity.plus.com
Sat Mar 26 13:06:01 EDT 2016


On 26/03/16 16:49, beliavsky--- via Python-list 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?

(e for i, e in enumerate(x) if i % n)

K.



More information about the Python-list mailing list