End of Summer - hours only!Up to 80% off on all courses and bundles.-Close
Sherlock Holmes
1. Introduction

Instruction

In this part, we'll play around with the text of "The Hound of the Baskervilles" by A. Conan Doyle*. We'll use Python to compute some statistics about the book. This way, you'll get to work with a text file and do some simple text data analysis!

*This eBook has been downloaded from www.gutenberg.org under the terms of the Gutenberg License.

Exercise

Let's start with reading in the contents of the book. The text of "The Hound of the Baskervilles" is in the file sherlock.txt. Read in the contents of the file and display it to the console.

Here's a reminder of how you can read a text file and display it to the console.

with open('filename.txt') as file: 
  file_data = file.read() # we read all contents of the 'filename.txt' 
  print(file_data)