I have written code to remove items in a list that contains a substring that matches another list. In other words, to remove items from cols if the item contains a substring from exclude_cols
exclude_cols =map(str.lower, exclude_cols)
exclude_cols.remove('')
for x in exclude_cols:
for c in cols:
if x in c:
#print "dropping ", x, c
cols.remove(c)
This partially works because I have to run it 3 times, to remove all the items needed. It is not iterating as I expect. Is there any other way I can accomplish the intent without running the same code multiple times?