Two sentences
Input
Hello world! This is a test.
Output
['Hello', 'This']
First sentence: 'Hello' and 'world' tie at length 5, but 'Hello' appears first. Second sentence: 'This' and 'test' tie at length 4, 'This' appears first.
Full lesson preview
Extract the longest word from each sentence in a text, preserving case and choosing the first occurrence on ties.
Problem statement
Task
Examples
Input
Hello world! This is a test.
Output
['Hello', 'This']
First sentence: 'Hello' and 'world' tie at length 5, but 'Hello' appears first. Second sentence: 'This' and 'test' tie at length 4, 'This' appears first.
Input format
Output format
Constraints
Samples
Input
The quick brown fox jumps over the lazy dog.
Output
['quick']
Only one sentence; 'quick' and 'brown' tie at length 5 but 'quick' appears first.