1with open("output.txt", "a") as f:
2 print("Hello StackOverflow!", file=f)
3 print("I have a question.", file=f)
4
1print("Hello stackoverflow!", file=open("output.txt", "a"))
2print("I have a question.", file=open("output.txt", "a"))
3
1#first arg is the name of the file
2#second arg notes that the file is open to write to it
3outputFile = open("fileName", "w")
4#next line writes to the file
5outputFile.write(str)
6#remember to close opened files
7outputFile.close()