PL/Python

[Python] filter 함수

SweetDev 2022. 11. 30. 12:23

 

articles = ["a", "an", "the", "and", "is", "or", "in", "only", "for", "to", "be", "it", "as", "of"]
def filtering_articles(w):
    if w not in articles:
        return w

text = " ".join(filter(filtering_articles, text.split()))