CJCoding With Joseph
15free / daySign inCreate account

Count The Words

Read one sentence and print three lines about its words: Words: <n>, the number of words; Longest: <word>, the longest word (on a tie keep the earlier one); and Letters: <n>, the total number of characters in all the words together. Split the sentence into a list with sentence.split(), which breaks it at the spaces and returns a list of the words, then get the count with len() and find the other two values with one for loop over the list. Input: one line, at least one word, no prompt.

Expected Output:

Words: 4
Longest: quick
Letters: 16

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Strings
📥 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.