(I see that this question is a duplicate. Sorry everybody, I wasn't sure of the wording so I couldn't find the other question)
I define the following list of strings:
x=["foo_a","foo_a_b","foo"]
then I do the following:
for i in x:
if (("a" not in i) or ("b" in i)):
x.remove(i)
and I get
In [92]: x
Out[92]: ['foo_a', 'foo']
I would expect the element "foo" to be removed too, because it doesn't contain "a" and so it doesn't verify the first condition.
What am I missing?