using dictionary to assign misspelled words to its line number
Posted
by jad
on Stack Overflow
See other posts from Stack Overflow
or by jad
Published on 2010-05-23T12:05:45Z
Indexed on
2010/05/23
12:10 UTC
Read the original article
Hit count: 210
python
This is the code I have so far
d = {}
counter = 0
for lines in words:
counter += 1
for word in text1:
if word not in words:
d[word] = [counter]
else:
d[word].append(counter)
print(word, d[counter])
words = my text file
text1 is my misspelled words
But this gives me an error. What I want to do is print the word and the line number e.g.
togeher 5 7
© Stack Overflow or respective owner