8. Try it yourself


Traceback (most recent call last):
File "python", line 1, in
AttributeError: exit

This is the error I get from the following code:

with ("text.txt", "w") as my_file:
my_file.write("Hello world")

Is there anything i can do to fix this?

thank you


Before ("text.txt", "w") as my_file: you have to open the file so you can write to it. So like,

with open("text.txt", "w") as my_file:


Then remember to print my_file so you can see the output.


Thank you so much. Usually I am more attentive. Thanks again


You're most welcome, if that was the answer you were looking for feel free to hit the solution button below my answer. :grin: