We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Count Words

Time for our first bit of data analysis! Let's count the words in the book.

Splitting a String

The str.split() method splits a string on whitespace characters like spaces and line breaks by default. It's an easy (though not entirely accurate) way to break a string into a list of words.

words = "Books are fun".split()
print(len(words))
# 3

The len() function then gives a word count.

Assignment

  1. Found {num_words} total words
    

    Replace {num_words} with the book's actual word count.

Run and submit the CLI tests from the root of your project.