I have this simple piece of code that tells me if a word in a given list appears in an article:
if not any(word in article.text for word in keywords):
print("Skipping article as there is no matching keyword\n")
What I need is if at least 3 words in the "keywords" list appear in the article - if they don't then it should skip the article.
Is there an easy way to do this? I can't seem to find anything.
sum(word in article.text for word in keywords) >= 3(write an explicit loop if you want to break earlier).