Download this file.
Feb 22, 18:01 - Ping (line 22): This is a somewhat inefficient way to deal with duplicate words, but it does work. (The count() function from the lab exercises is a more efficient way.)
Please log in if you would like to add comments. | |
1 | """ also assumed that findword loaded the dictionary within it """ | 2 | | 3 | wordList = [] | 4 | | 5 | file = open("input.txt") | 6 | for line in file: | 7 | wordList.extend(line.split()) | 8 | | 9 | misspelledWords = [] | 10 | | 11 | for word in wordList: | 12 | if isword(word): | 13 | if not findword(word): | 14 | misspelledWords.append(word) | 15 | | 16 | misspelledWords.sort() | 17 | | 18 | for item in misspelledWords: | 19 | numberOfTimes = misspelledWords.count(item) | 20 | print item, '(', numberOfTimes, ')' | 21 | while misspelledWords.count(item) > 1: | 22 | misspelledWords.pop(misspelledWords.index(item)) |
|