I need to remove from my_list
anything that contains any substring from banned
(both lists are very long, approximately 30k+).
Here's a mini example:
my_list = ['dnb','distinctive_group_inc','real-estate-profile','estate.com']
banned = ['distinctive','estate']
Desired outcome:
my_list = ['dnb']
I'd like to be able to do it in one go so I tried:
my_list = [i for i in banned if i not in my_list]
Since that didn't work at all, I tried it in two steps:
for i in reversed(my_list):
for j in banned:
if j in i:
my_list.remove(i)
else:
pass
How can I do it in one step?