Loading...
Loading...
Loading...
A reading tool finds the longest word in a sentence. Read one line, find the longest word and print it with its length, separated by a space.
If two words are equally long, print the one that comes first.
Example
Input
the quick brown fox
Output
quick 5
quick and brown both have 5 letters. quick comes first.
Try the problem first. Open one hint at a time.
Keep the best word so far, starting from an empty string.
Replace it only when a word is strictly longer, so ties keep the earlier word.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor