how to print the linenumber of incorrectwords located in a txt file ?
- by jad
i have this piece of code which only prints the line number of the incorrect words.
i want it to print the linenumbers of the incorrect words from the txt file.
Am i able to modify this code to do that?
# text1 is my incorrect words
# words is my text file where my incorrect word are in
from collections import defaultdict
d = defaultdict(list)
for lineno, word in enumerate(text1):
d[word].append(lineno)
print(d)