remove punctuations from a sentence and split the sentence into a list
def remove_punc_split(text): # replace punctuations with spaces text = re.sub('[^\w\s]', ' ', text) return text.split() remove_punc_split('This!! is? a sentence.') # returns ['This', 'is', 'a', 'sentence']