Words in a Sentence
Programs with input · Intermediate · about 7 min
Read a sentence and print how many words it has and its longest word, as Words: 6 and Longest word: library. Words are separated by one or more spaces, and the sentences have no punctuation. If two words tie for the longest, print the one that comes first.
The prompts inside input() are not checked, only what you print.
Example
You type:
My school has a big library
The program prints:
Words: 6 Longest word: library
sentence = input("Sentence: ")
# Print the number of words and the longest word
The solution opens after your first Check.