I have a list of strings stored in a variable pdf paths, and I have another list of strings that if any item in my pdf paths list contains, it should be removed.
It works for some strings but not for others even though the string contain the same word.
def remove_derivaties(blacklist, pdf_list):
for x in blacklist:
for y in pdf_list:
if x in y:
pdf_list.remove(y)
return pdf_list
def main():
string = ["P:\\Example Files\\Latest\\PRM-FRM-011 Calc Review Form.pdf",
"P:\\Example Files\\Latest\\PRM-FRM-003 Project Assignment Form.pdf",
"control_string"]
exclude = ["P:\\Example Files",
"control_string1"]
not_excluded = remove_derivaties(exclude, string)
print(not_excluded)
The output is ['P:\\Example Files\\Latest\\PRM-FRM-003 Project Assignment Form.pdf', 'control_string']
yet the exclude word is contained in both strings