Stop words

danbihan · updated November 14, 2021
stopwords = [
    'I', 
    'as', 
    'to', 
    'you', 
    'your', 
    'but', 
    'be', 
    'a',
]
paragraph = 'I want to figure out how I can be a better power napper'

def stopwords_stripped(paragraph, stopwords):
    
    words_list = paragraph.split(' ')
    cleaned_list = [word.lower() for word in words_list if word not in stopwords]
    cleaned_str = ' '.join(cleaned_list)
    
    return cleaned_str
    
print(stopwords_stripped(paragraph, stopwords))
Output

Comments

Please sign up or log in to contribute to the discussion.