Python Program to Append to a File

bookmark

with open("my_file.txt", "a") as f:
   f.write("new text")

 

The content of the file my_file.txt is

honda 1948
mercedes 1926
ford 1903

Output

honda 1948
mercedes 1926
ford 1903new text