Additional Practice

Loops and Conditionals

In order to practice use of loops and conditionals, we wanted to play with an easily accessible data set. Our solution is to use a system-wide list of words and phrases that supports spell-checking and other language tools. We load those words into a Python list with the following command:

words = [line.strip() for line in open('/usr/share/dict/words') if line.strip()]

Here is the final version of words.py that we had by the end of lecture this day.


Last modified: Tuesday, 15 February 2011