← Back to Files
Question 410
Word Count From A File
Word Count From A File
The sentence read from input is written to story.txt. Open the file for reading, read the whole content with f.read() into text, break it into words with split() (no argument, so any run of whitespace separates words) and print the number of words as one number. Input: one line, no prompt.
Expected Output:
4= newline. The output ends with a newline — print one after the last line.
Hints3 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.