write in a file with python by appening next contains code example
Example 1: python append to file
with open(filename, "a+") as f:
f.write('Hello World')
Example 2: python write file
with open("file.txt", "w") as file:
for line in ["hello", "world"]:
file.write(line)