Ex 16 LPTHW3 - Why can't I read the file I just edited


#1

Hi all,

I have a question regarding exercise 16.

After line 30, I tried to put the following line in order to have the (edited) file “printed”:
print(target.read()).

Unfortunately, I receive an error message saying that the file is not readable.
I understood this is due to the ‘w’ in line 12, in the open function.
Can somebody explain me more about this?

Thanks for the help!


#2

Hello @Nickroma89.
I guess you want to read the three lines before closing.

You have to add before your line:

target = open(filename. 'r') 

Then it is available for printing out.