I am quite new to Python, and the following puzzles me, maybe there is someone here who can tell me what is wrong?
I have a list of words in a plain textfile (encoded in latin-1). There is one word per line, and 106299 words in total. I want to load the words to a list because I want to manipulate them, and then write them to a different file...
The mystery for me is that the new file only contains 106211 lines, even though I have not done anything with the list yet, and the last line contains a word that has been truncated.
I have tried many different version of the program, but this is the most basic one, and it gives the error mentioned above:
Expand|Select|Wrap|Line Numbers
- f = open("list.txt", "r")
- wordlist = [w.lower() for w in f.readlines()]
- f.close
- f = open("new_list.txt", "w")
- f.writelines(wordlist)
- f.close