End of Summer - hours only!Up to 80% off on all courses and bundles.-Close
Sherlock Holmes
2. Get the list of words


Keep it up, dear Watson! We're interested in investigating the words that "The Hound of the Baskervilles" contains.


Write a function get_words_list() that takes the filename as its argument and returns the list of words that the text file contains. The function should read in the file, split it into words, and return the list of words.

Then use your function to display to the console how many words there are in "The Hound of the Baskervilles" (just print the number). The text of the book is available in file sherlock.txt.

Stuck? Here's a hint!

To split the text content into words you can use the split() function. Look at the example:

words_list = file_data.split() # we split the contents into the list

The split() function splits the contents of the file into a list of words, using space or the end of line as word delimiters.