In the previous tutorial, we introduced Python’s most common data types: numbers (ints and floats), strings, lists, tuples and dictionaries. We demonstrated how they work with different operators, and explained a few of their most useful methods. We didn’t, however, give much insight into how they might be used in real situations. In this article, we’re going to fix that.
We’re going to write a program that counts the number of times each unique word occurs in a text file. Punctuation marks will be excluded, and if the same word occurs but in different cases (for example, the and The), they will be taken to represent a single word. Finally, the program will print the results to the screen. It should look like this:
As an example, we’ll be using…
