remove element if it has a certain string in it

list, python

Solution

You mean something like this:

>>> lst = ['1 2 4 5 0.9','1 2 4 5 0.6','1 2 4 5 0.3','1 2 4 5 0.4']
>>> s = set([0.9,0.3,0.7,0.8])
>>> [x for x in lst if float(x.split()[-1]) not in s]
['1 2 4 5 0.6', '1 2 4 5 0.4']

Problem

I have a list `['1 2 4 5 0.9', '1 2 4 5 0.6', '1 2 4 5 0.3', '1 2 4 5 0.4']` I also have another list: `[0.9, 0.3, 0.7, 0.8]` I want to use the second list and the first list elements include whats in the second list then the element gets removed, so the first list ends up like: ``` [1 2 4 5 0.6', '1 2 4 5 0.4'] ```

Original source