On 03/26/2016 09:49 AM, 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?

Yes:

>>> L=list(range(20))
>>> [x   for i,x in enumerate(L)   if i%3 != 0]
[1, 2, 4, 5, 7, 8, 10, 11, 13, 14, 16, 17, 19]


Gary Herron


--
Dr. Gary Herron
Department of Computer Science
DigiPen Institute of Technology
(425) 895-4418

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to