Given two lists: list1
containing sentences and list2
containing words, I want to find the sentences of list1
having all the words belonging to list2
.
list1 = ['p jthputmxy xpih t zdamz', 'l kefylcbfl tpij p jonvs', 'c olqlyfxew ksah p opjto', 'o cbfolbbwa fcha b xcruo', 'x iirvablmi dvqg i jjguy', 'c ocqlyfoew ksrh p opato', 'n cyjelcxxy xlip t kvrks', 'l kajltafti egei a bzzts', 'p ctjpltfxa xgia t bdrms', 'a cavalaria esta a norte']
list2 = ['atacar', 'esperar', 'noite', 'base', 'sul', 'norte', 'cavalaria', 'esta', 'a', 'pato']
desired output = [False, False, False, False, False, False, False, False, False, True]
My code so far:
test = [all(i for i in list2) for f in list1]
return test
Only returns:
[True, True, True, True, True, True, True, True, True, True]