CJCoding With Joseph
15free / daySign inCreate account

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
Topics:
Files
📥 Auto-Input:
the quick brown fox\n
This input is automatically fed to your program's stdin
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.