Suppose
x = range(20)
k = 5
x_kth = x[::5]
That gives me 0,5,10,15 etc
Is there any easy way to get the non kth elements in x?
x_nonkth = [1,2,3,4,6,7,8,9,11 etc
I know I can do
x_nonkth = [x[i] for i in range(len(x)) if i%k]
But I am looking for an easier way (and possibly faster?) if there is any.
You can make use of
setdifference: –