2. The open() Function


#1

Here is my code. I don't really know what the problem is. All help is appreciated!

my_file = open("output.txt", "r+")


#2

your code is correct , try to write something on output file and save it !!


#3

I have that code written as well but I keep getting an error prompt that tells me to create a variable for "my_file". Is anybody else experiencing this?


#4

Yep :confused: I can not seem to get it either.


#5

I got the same problem with you. And my code just look the same as yours, but i have passed it.
What i did is to copy the code from last lesson "File Input/Output":f = open("output.txt", "w") and change f to my_file and "w" to "r+", then passed.
I think there might be something wrong with the format of punctuation mark or something....


#6

Thank you for this one :slight_smile:


#7

you can also go to the tab output.txt and just write something in there.
then it will succeed.


#8

Reload the page, go back to 1. See It to Believe It, and click Save & Submit code. Then hit Save & Submit code on 2. The open() Function and it should work.

It seems like you need to remind codecademy that the output.txt file exists.


#9

This works, thanks a lot!