From the course: Python Data Analysis

Unlock the full course today

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

Loading a dictionary

Loading a dictionary - Python Tutorial

From the course: Python Data Analysis

Start my 1-month free trial

Loading a dictionary

- [Instructor] We begin. By loading a list of words from a file. Your exercise files. Already contain a list that we can use as an example. The file is words.txt and it sits in the same folder as this Jupyter notebook. That file is, in fact, the nineteen thirty four dictionary. That is distributed with many UNIX systems. If you wish, you can find a better one and use that instead. Now in Python. We talk of idioms to refer to code constructs. That have become the preferred way to achieve a certain goal. A classical example is looping through all the lines of a text files. To do so. We open the file for reading. Let's open with a mode of "R" and then, we can use the file as an iterable. In a fold loop. Which has the result or giving us the lines one by one. For the moment. All that we will do with each line, is just collect it in a list. What did we get? More than two hundred thousand words. Let's…

Contents