All problems
Sentence Splitter
Problem
Split text into sentences. A sentence ends after a maximal run of '.', '!' or '?' characters; any leftover text at the end is a sentence.
Strip surrounding whitespace and drop empty pieces, but keep the punctuation inside its sentence.
Hint
Track the start of the current sentence and scan for punctuation runs.
Test cases
case 1
in: ["Hello world. How are you? Fine!"]
expected: ["Hello world.","How are you?","Fine!"]
case 2
in: ["No punctuation here"]
expected: ["No punctuation here"]
case 3
in: [""]
expected: []
case 4
in: ["One. Two.. Three"]
expected: ["One.","Two..","Three"]
case 5
in: ["Wait... really?!"]
expected: ["Wait...","really?!"]
Starter codePython
def sentence_split(text):
# Your code here
pass5 test cases · run your code against them in the editor