if line not startswith item from a list

python

Solution

`str.startswith()` can take a tuple of strings to test for:

prefix can also be a tuple of prefixes to look for.

Use this together with a list comprehension:

identifier_list = ('CON', 'VEN', 'PLE')  # tuple, not list

[elem for elem in list_results if not elem.startswith(identifier_list)]

Demo:

>>> list_results = ['CONisotig124', '214124', '2151235', '235235', 'PLEisotig1235', 'PLEisotig2354', '12512515', 'CONisotig1325', '21352']
>>> identifier_list = ('CON', 'VEN', 'PLE')  # tuple, not list
>>> [elem for elem in list_results if not elem.startswith(identifier_list)]
['214124', '2151235', '235235', '12512515', '21352']

Problem

I would like to know how to take those items from a list that don't start like some of the items from another list. I want to make something like: ``` list_results = ['CONisotig124', '214124', '2151235', '235235', 'PLEisotig1235', 'PLEisotig2354', '12512515', 'CONisotig1325', '21352'] identifier_list=['CON','VEN','PLE'] for item in list_results: if not item.startswith( "some ID from the identifier_list" ): print item ``` So, how do I say: ``` if not item.startswith( "some ID from the identifier_list" ): ```

Original source