how to add data to a text file in python code example Example: python append to file with open(filename, "a+") as f: f.write('Hello World')