How often does a word appear in a text?
A line containing a word, followed by a line containing a text.
The number of occurrences of the word in the text. Capitals and lower case letters may both be used, and you have to consider that the word should be a separate word, and not part of another word.
Tip
If you did the exercises from this chapter, you already developed a function that “cleans” a text. Combining that function with the
split()
function more or less solves the problem for you.
wood
How much wood would a woodchuck chuck if a woodchuck could chuck wood? He would chuck, he would, as much as he could, and chuck as much as a woodchuck would If a woodchuck could chuck wood.
Number of times "wood" occurs in the text: 3