python save print statements to text file and output code example
Example 1: print output python to file
print("Hello stackoverflow!", file=open("output.txt", "a"))
print("I have a question.", file=open("output.txt", "a"))
Example 2: python output to text file
$ python my_program.py > output.txt