Cody Bable

Generation

generate functionWed, 19 Apr 2023

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']

Questions about programming?Chat with your personal AI assistant