Answer the question
In order to leave comments, you need to log in
How to remove an element from a list whose part is in another list?
There are lists:
list = ['text 1', 'text 2', 'text 3' , 'text 4']
list2 = ['1', '2']
text3
text4
Answer the question
In order to leave comments, you need to log in
list1 = ['text 1', 'text 2', 'text 3' , 'text 4']
list2 = ['1', '2']
[x for x in list1 if not any([y in x for y in list2])]
# ['text 3', 'text 4']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question