8. Try it yourself


#1

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


#2

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:


#3

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


#4

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


#5

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