8/9 Try it yourself help


#1

Hey my code below isn't working and I'm not too sure what to do to fix it. The error that keeps coming up is "Oops, try again. Did you create a variable called my_file?"

I've read other solutions posted and I have the same thing but mine isn't working.
I initally had the same code without the last two lines (print and close statements).

Does anyone know what I need to do? Any help is appreciated!


with open("text.txt", "w") in my_file:
    my_file.write("Did it work?")
    
print my_file
my_file.close()

Thanks.


#2

Woooooow. Don't worry guys! As soon as I went back to the problem after posting this I saw the issue.

It was my 'in' instead of 'as'!

Thanks.


#3

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