On 26.03.2016 18:06, Peter Otten wrote:
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?
del x[::n]
;)
Actually quite nice.
--
https://mail.python.org/mailman/listinfo/python-list
On 26/03/2016 22:08, beliavsky--- via Python-list wrote:
On Saturday, March 26, 2016 at 1:02:06 PM UTC-4, Gary Herron wrote:
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
On Saturday, March 26, 2016 at 1:02:06 PM UTC-4, Gary Herron wrote:
> 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:
>
> >>>
On 26/03/2016 16:49, beliav...@aol.com wrote:
I can use x[::n] to select every nth element of a list.
I would use x[n-1::n] if 'nth' means the 3rd element of
[10,20,30,40,...] is 30. Otherwise every selection will include the
first, no matter what n is.
--
Bartc
--
Le 26/03/2016 18:06, Vincent Vande Vyvre a écrit :
Le 26/03/2016 17:49, beliavsky--- via Python-list a écrit :
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?
Something like that:
>>> l = list("lkodjuyhrtgfedcvfg")
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?
del x[::n]
;)
--
https://mail.python.org/mailman/listinfo/python-list
Le 26/03/2016 17:49, beliavsky--- via Python-list a écrit :
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?
Something like that:
>>> l = list("lkodjuyhrtgfedcvfg")
>>> l
['l', 'k', 'o', 'd', 'j', 'u', 'y', 'h', 'r',
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.
--
https://mail.python.org/mailman/listinfo/python-list
On Mar 26, 2016 12:50 PM, "beliavsky--- via Python-list" <
python-list@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]
--
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,
10 matches
Mail list logo