112k views
19 votes
Write a program that opens an output file with the filename my_name.txt, writes your name to the file, then closes the file. python

1 Answer

9 votes

f = open("my_name.txt", "w")

f.write("Your name here")

f.close()

You just have to change Your name here to your actual name. I wrote my code in python 3.8. I hope this helps.

User Judine
by
5.8k points