One of the challenges of working with large amounts of data in a program is how to do it efficiently. In Python importing the code could not be easier, but everything gets bogged down when you try to work with it and search for items inside of modify it. In these next few examples I will provide several solutions to working with a word list containing practically every word in the English Language to solve various problems.

If you are new to Python - a great first language - everything can be downloaded from here 

Attached is the actual word lists in a .txt file. There are 113,808 individual words, each on their own line.

When you run the program the script and word list need to be in the same folder, otherwise you will get an error to the effect of "no such file exists"

Step 1: Helpful Code Sections

Before we begin there are a couple of lines of code that you might find helpful for interpreting what is going on if Python is still new to you.

fin = open('words.txt')  - This line opens up the file (it can be any file)
for line in fin: - This line goes through the file one line at a time up until the 113,809th line
word = line.strip() - This line removes all the white space and formatting so that only the characters in the specific line are stored in a string with variable name word.
Bigger word list (178 691 words):<br> <a href="http://www.freescrabbledictionary.com/twl06.txt" rel="nofollow">http://www.freescrabbledictionary.com/twl06.txt</a>
These will save my life :) I did some before but definitely needed some for analyzing data! Thanks!
Glad to help. It is really amazing the way that Python can sort through text. Please let me know if you have any questions or need help.
nice, I think I've done some of these before too!

About This Instructable


9 favorites


Bio: From solder to zip ties, lead acid batteries and LEDs, and especially Legos, putting things together has always fascinated me. The more challenging the better ... More »
More by Hammock Boy: Chipper Board - ATtiny Programming Shield Boxhead recreated with Python with Tkinter Interface Python and Arduino with pySerial
Add instructable to: