I have two lists ready. The first one is a list of common words as such:
common_word = ['a', 'about', 'all', 'also', 'and', 'as', 'at', 'be', 'because', 'but', 'by', 'can', 'come', 'could', 'day', 'do', 'even', 'find',
'first', 'for', 'from', 'get', 'give', 'go', 'have', 'he', 'her', 'here', 'him', 'his', 'how', 'i', 'if', 'in', 'into', 'it', 'its
', 'just', 'know', 'like', 'look', 'make', 'man', 'many', 'me', 'more', 'my', 'new', 'no', 'not', 'now', 'of', 'on', 'one', 'only',
'or', 'other', 'our', 'out', 'people', 'say', 'see', 'she', 'so', 'some', 'take', 'tell', 'than', 'that', 'the', 'their', 'them',
'then', 'there', 'these', 'they', 'thing', 'think', 'this', 'those', 'time', 'to', 'two', 'up', 'use', 'very', 'want', 'way', 'we',
'well', 'what', 'when', 'which', 'who', 'will', 'with', 'would', 'year', 'you', 'your']
The other list is:
msg_clean = [['great', 'servuce'], ['loved', 'it'], ['great', 'nails', 'lasted', 'almost', 'weeks', 'without', 'chipping'], ['very', 'clean', '
and', 'attentive', 'came', 'in', 'early', 'for', 'an', 'appointement', 'and', 'they', 'seated', 'me', 'right', 'away', 'i', 'came',
'in', 'for', 'a', 'gel', 'manicure', 'and', 'really', 'cool', 'they', 'have', 'the', 'uv', 'dryers', 'installed', 'right', 'into',
'the', 'tables', 'everyone', 'is', 'super', 'friendly', 'too', 'highly', 'recommend', 'a'], ['i’ve', 'been', 'coming', 'here', 'fo
r', 'the', 'past', 'years', 'and', 'the', 'service', 'is', 'impeccable']]
However, when I try to find and remove the common word in the second list, only some common words are removed and others stay.
My code is:
for item in msg_clean:
for words in item:
if words in common_words: item.remove(words)
However, the output is something like the following:
[['great', 'servuce'], ['loved'], ['great', 'nails', 'lasted', 'almost', 'weeks', 'without', 'chipping'], ['clean', 'attentive', 'c
ame', 'early', 'an', 'appointement', 'seated', 'right', 'away', 'came', 'for', 'gel', 'manicure', 'really', 'cool', 'they', 'have',
'uv', 'dryers', 'installed', 'right', 'the', 'tables', 'everyone', 'is', 'super', 'friendly', 'too', 'highly', 'recommend'], ['i’v
e', 'been', 'coming', 'for', 'past', 'years', 'the', 'service', 'is', 'impeccable']]
As you can see, some word such as 'is' is not removed, but 'it' is removed. Thanks in advance for your help.