Finding words in a text file witch they have double letters via python scrabble…

Mehrdad Zadehebrahim
1 min readNov 20, 2021

Here I have a very very long text file with many words..

we can find words with specific feature like double letters ( in this case “ee”) in 3 simple steps:

step 1:

make a folder in linux terminal for your work space and call it what ever U want:

mkdir MyWorkSpace

step2:

make a file to write scrabble module:

touch scrabble.py

step3:

open the file with your favorite IDE, mine is SublimeText ,

here is the code:

WORD_LIST = “sowpods.txt”

wordlist = open(WORD_LIST).readlines()

# Get rid of newLines

wordList = [word.lower().strip() for word in wordlist]

in first line, you put your text file into a variable, then you read it line by line and assign it to a list, called word list. then you separate your text into single words.

so..

in step 4:

make new file called word.py:

touch word.py

then open it in ide, and write this code:

import scrabble

import string

for word in scrabble.wordlist:

if “ee” in word:

print(word)

first import scrabble module witch you have written before,

then import string module,

then search for “ee”

Nice!

Here is the link in github:

https://github.com/mehrdad-za/pydic

--

--

Mehrdad Zadehebrahim

Former php programmer, now, python and js - interested in data science, math and..