I have a list of lists as follows.
mylist = [["i", "love", "to", "eat", "tim tam"], ["tim tam", "is", "my", "favourite",
"chocolate", "and", "i", "eat", "it", "everyday"]]
I also have a list namely stops
as below.
stops = ["and", "the", "up" "to", "is", "i", "it"]
Now, I want to search through mylist
and remove the aforementioned stops
from it. Hence, my final mylist
will look as below.
mylist = [["love", "eat", "tim tam"], ["tim tam", "my", "favourite", "chocolate", "eat", "everyday"]]
My current code is as follows.
for k in mylist:
for item in k:
if k in stops:
pop(k)
It gives me TypeError: unhashable type: 'list'
. Please help me.