Say I have a list:
my_list = ["A", "B", "haha_test_haha", "C"]
I want to remove any and all elements that hold the substring test
.
Output:
my_list = ["A", "B", "C"]
I've been trying list comprehensions with no luck. This would be the desired solution.
Note: I need only test
to be removed. Not a list of words to remove.
My attempt:
my_list = ['A', 'B', 'C', 'C', 'ahahtestaagaga']
my_list = [remove for e in my_list if e.substring('test')]
print([sa for sa in a if not any(sb in sa for sb in b)])