Practice
Tokenise a Sentence into Words
2023/May/June·Variant 1
MEDIUMString Processing
A sentence contains words separated by single spaces, with no leading or trailing spaces. Write procedure SplitWords(Sentence) that outputs each word on its own line.
Input: One sentence. Output: Each word on its own line.
Example:
Input: The cat sat
Output: The
cat
sat
Premium is coming soon. All grading features are currently unlocked.
Sample Test Cases
Test 1: Three words
Inputs: The cat sat
Expected: The
cat
sat
Test 2: Single word, no spaces
Inputs: Hello
Expected: Hello