I have a lists:
my_list = [\'abc-123\', \'def-456\', \'ghi-789\', \'abc-456\', \'def-111\', \'qwe-111\'] bad = [\'abc\', \'def\']
and want
some_list = ['abc-123', 'def-456', 'ghi-789', 'abc-456'] bad = ['abc', 'def'] for s in some_list: for item in bad: if item in s: print 'Found ', s
It's simple, works fine and fast( only if your list is not very big.)