← Back to Files
Question 431
Wordiest Line
Wordiest Line
Input: three lines of text, no prompt. Write them to lines.txt one per line, then read the file back and find the line with the most words, splitting each line on whitespace with split() after removing its newline with rstrip; when two lines tie, keep the earlier one. Print <line> (<n> words) with the winning line and its word count.
Expected Output:
one two three four (4 words)= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Files
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.