[Solved] Finding lines that include two or more words from a list

[ad_1]

Here is one way

if len(set(line.split()).intersection(keywords)) > 2:

This splits the line into words with line.split() first
. Then uses sets intersection function to find the common elements of 2 sets

3

[ad_2]

solved Finding lines that include two or more words from a list