All problems
Count Words in a Sentence
easyPythonStrings
A classifieds site charges by the word, so the listing form shows a live word count as the seller types the description. A word here is a run of characters with a space on either side of it — no cleverness about hyphens or punctuation.
Task: Read one description and print how many words it contains.
Input
A single line holding a sentence of 1 to 200 characters. Words are made of lowercase letters and are separated by single spaces. There is at least one word.
Output
One line holding a single integer: the number of words in the sentence.
Example:
Input:
the quick brown fox
Output:
4
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in