9. Case Closed?


whats wrong with my code? it passes through the code academy despite the ınterpretor giving an error message?

with open("text.txt", "r+") as my_file:
    if my_file.closed== False:
print my_file.closed


Hi @objectplayer39020,

Most likely, your code raised the error because the text.txt file did not yet exist as you started this exercise. The instructions did not state that the file needed to be created, so the problem might best be viewed as Codecademy's fault, more than yours. This set of exercises does seem to be a little buggy.

To compensate for the glitch, open the file in "w+" mode so that if the file does not exist, it gets created. If it does already exist, it will get truncated as it is opened.

Congrats for completing the final Python exercise. :smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.