Correction

Report a typo

How would you correct the first line of code so that it would work?

text_file = 'text_file.txt'                                  # 1
print('The specified string to be written', file=text_file)  # 2
text_file.close()                                            # 3

In the answer, write the given line with your modifications.

Tip: Shouldn't you open a file before writing to it?

Enter a short text
___

Create a free account to access the full topic