I have been trying to work on this certain pattern for quite some time but I am unable to come up with a solution. For example I have list like: n = ['M', 'M', 'B', 'B']
.
Now, I know how to remove the elements from a list that have odd indexes or even indexes like del n[1::2]
for odd indexes and del n[0::2]
for even indexes.
However, I am looking to remove in a pattern like this: 0, [1], 2, [3], [5], [8].....
so on and so forth. The brackets are for the elements in those certain indexes to be removed.
The n
list is just an example, I have much larger lists with more elements. So far, all the things I have tried haven't worked and I would appreciate any help on this. Thanks.