I have a nested list of the following structure:
nested = [["a","b"], ["c", "d"]]
I now want to stick to this structure, but remove elements if they belong to another list.
Imagine this list to be stoplist = ["a","z"]
So the result would be:
[["b"], ["c", "d"]]
I am hoping I am missing a simple thing here, but I just can't seem to get the list comprehension in this case:
[letter for letter in List if letter not in stoplist for List in nested],
it runs, but it gives back this result: ['c', 'c', 'd', 'd']
What is going on, and how to solve this?
Note: I understand this can be done with append, but I would prefer to avoid this, as I will be working with big files.
stoplistto a set.