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']
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']
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With