I want the text to be one key: the number per line. Right now, it saves the file as a simple dictionary, and I cannot figure it out.
def makeFile(textSorted, newFile) :
dictionary = {}
counts = {}
for word in textSorted :
dictionary[word] = counts
counts[word] = counts.get(word, 0) + 1
with open(newFile, "w") as file :
file.write(str(counts))
file.close()
return counts
user4951691
source
share