Trying to test if file is closed and to close it if not but keep getting
"Traceback (most recent call last):
File "python", line 5, in
TypeError: 'bool' object is not callable"
and "Oops, try again. You don't need any parentheses after 'closed'—just my_file.closed should do the trick."
But when I remove the paentheses I get
"Oops, try again. Did you call my_file.close() in the event that my_file.closed returns False?"
with open("text.txt", "w") as my_file: my_file.write("Helli") if not my_file.closed: my_file.closed() print my_file.closed