From the course: Effective Serialization with Python

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Challenge: Counting strings

Challenge: Counting strings - Python Tutorial

From the course: Effective Serialization with Python

Start my 1-month free trial

Challenge: Counting strings

(upbeat music) - [Instructor] In the exercise files, you'll find words.txt with one word per line. Your task is to print the words with their count to the standard output. In this case, I'm using counter. And then for every word in the file, I'm using strip to remove white space and then increment the counter for the word in one. And finally, I print out the words and the count. However, when you run this code, python wc.py, We see that, for example, PYTHON with uppercase and python with lowercase are treated separately. Fix the bug.

Contents