Skip to content

Instantly share code, notes, and snippets.

@muxueqz
Forked from anonymous/gist:7f3ab5183d519b0a8e80
Last active August 29, 2015 14:23
Show Gist options
  • Save muxueqz/3aebbcb80199fb85d04e to your computer and use it in GitHub Desktop.
Save muxueqz/3aebbcb80199fb85d04e to your computer and use it in GitHub Desktop.
worddict = set()
with open ('words.txt') as fh:
lines = fh.readlines()
for element in lines:
words = element.rstrip()
worddict.add(words)
print '{0} words in spelling words'.format(len(worddict))
with open ('3-2_example.txt') as ex:
# exlines = ex.read().split()
# exlines = ex.read().split('\n')
count = 0
# for exelement in exlines:
for line in ex.readlines():
count = count + 1
for exelement in line.split():
exwords = exelement.strip('.').strip(',').strip(';').strip(':').lower()
if exwords not in worddict:
print 'misspelled word on line {0}: {1}'.format(count, exwords)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment