105. Python Program to Count the Words in a Sentence
EasySplit and join
Overview
Turn a sentence into a list of words, then count the list.
Problem Statement
Read a sentence and print how many words it has. Words are separated by one or more spaces, and there may be spaces at the ends. For example, for Python is fun:
Words: 3
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One line of text. Example:
Python is fun
Output
The output for that example:
Words: 3
The tests try 4 different inputs, including one with extra spaces.