Course Home | Assignments | Class Photo | Computing Resources | Lab Hours/Tutoring | Python | Schedule

Saint Louis University

Computer Science 150
Introduction to Object-Oriented Programming

Michael Goldwasser

Spring 2011

Dept. of Math & Computer Science

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.


Michael Goldwasser
CSCI 150, Spring 2011
Last modified: Tuesday, 15 February 2011
Course Home | Assignments | Class Photo | Computing Resources | Lab Hours/Tutoring | Python | Schedule