xs = ['abc-123', 'def-456', 'ghi-789', 'abc-456'] if any("abc" in s for s in xs): ...
matching = [s for s in xs if "abc" in s]