Practice
Split Sentence Into Words
2026/Feb/Mar·Variant 2·Q6·[8 marks]
MEDIUMString Processing
Read one sentence whose words are separated by single spaces (no leading or trailing space). Output each word followed by a space and its length.
Input: One line of text.
Output: One line per word: <word> <length>.
Example:
Input: Computing is fun
Output: Computing 9
is 2
fun 3
Sample Test Cases
Test 1: Three words
Inputs: Computing is fun
Expected: Computing 9
is 2
fun 3
Test 2: Single word
Inputs: Hello
Expected: Hello 5