Im trying to count the amount of words in a text document then write the total back to the .txt
here is how far i've got
words = 0
f = open("count.txt", 'r+')
for wordcount in f.readline().split(" "):
words += 1
print('number of words ')
print(words)
f.write("number of words ")
f.write(words)
f.close()
I get this error
TypeError: expected a character buffer object
Where am I going wrong?
i feel that f.write(words)
isn't the correct way to write the total to the txt?