remove_stopwords(words, stopwords) that returns the input list of words with every stopword removed, preserving the original order of the survivors. Convert stopwords to a set first so each lookup is O(1) instead of scanning a list.remove_stopwords(['the', 'cat', 'on', 'mat'], ['the', 'on', 'a'])
['cat', 'mat']
the and on are stopwords; order of the rest is preserved.
Membership tests on a set are constant time.
A simple loop or comprehension with "not in" finishes it.