Please, nooo ![]()
This is against important good manners in programming style, a way how to create obscure code.
The comprehensions / generator expressions are functional style. You are supposed to read data, and make new data from them. Here you are modifying the original data using the methods list.pop() and list.remove(). Please do not misuse comprehensions as another way to write a for loop. If you want to perform side-effects, use a for loop.
No, this code checks that a string in the last element of iterable ss starts with X1:
Implementation in the functional style:
Input data
s = [['X1:', '99'], ['X1: Cheese'], ['99'],['X1: Cheese2'],['X1: Cheese3'],
['X1: Cheese4'],['X1: blah blah','99','98']]
List comprehension (split to multiple lines for readability):
[
item for item in s
if not(len(item) == 1 and item[0].startswith('X1:'))]
You can replace the square brackets for round ones to get a generator.
The old-school functional style:
filter(lambda item: not(len(item) == 1 and item[0].startswith('X1:')), s)
Result (after storing to a list)
[['X1:', '99'], ['99'], ['X1: blah blah', '99', '98']]