Read the question, write Python on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read one line of text and print how many words it contains.
The trick is that .split() with no argument treats any run of whitespace as a single separator, so double spaces do not fool it.
Input. One line of text.
Output. One integer: the word count.
Examples
Input
the quick brown fox
Output
4
Input
hello world
Output
2
Hint
- input().split() returns a list of words.
- len(...) of that list is your answer.
Show correct code
Peek only after you have tried. You can still Check your own version.
print(len(input().split()))
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.