1 Answer
+ 3
This can be achieved by setting the mode in open() to "a" (append) instead of "w" (write).
For instance:
open("test.txt", "a") as myfile: myfile.write("appended text")
In case you want to edit a specific line instead of appending, check this example: https://www.kite.com/JUMP_LINK__&&__python__&&__JUMP_LINK/answers/how-to-edit-a-specific-line-in-a-text-file-in-python