I have this problem and I am looking forward to see your positive answers and solutions. the codes bellow: when the program detects misspelled words after the text split it append each misspelled word into a list [a] and now my problem is that how can I write(update) to dictionary with the misspelled words in a way that each line in the dictionary contains only one word. so far I have tried and it only writes the current insert and deletes the previous records. any help is appreciated ( THANKS)
def onaddbutton(self,event):
os.chdir('d:/KKSC')
dic = getDic()
print dic[0], dic[1], dic[2]
text = tokenize_editor_text(self.controlz.GetValue())
a = []
for word in text:
if word not in dic:
misspelled = word
a.append(misspelled)
f= (misspelled)
with open('test.text', encoding='utf-8', mode='w') as f:
f.write(misspelled)
f.write('\n')
f.seek(0)
print(repr(f.readline()[:1]))
Please update your indentation.
you're problem is you're opening the file with mode="w". Try mode="a" for append instead.
Also, seek(0) will move the current position in the file to the first line, first column. That isn't what you seem to want. Get rid of that line.