Writing to file

Report a typo

As you have learned, the print() function is an alternative to the file.write() function. Now, let's write to a file "A string to be written to a file!" using the print() function.

The file name to use is "test.txt", and all next steps you should perform by yourself.

Write a program in Python 3
f_name = "test.txt"
my_string = "A string to be written to a file!"

# what to do with the file and the string

Create a free account to access the full topic