2 open (input/output-2.open)


#1

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

??????????????????


#2

@scriptjumper86993,
You are trying to open a file that does NOT exist.......

With

import os
print "==show us the existing files =="
files = [f for f in os.listdir('.') if os.path.isfile(f)]
for f in files:
    print str(f)
#my_file.close()

you will see all the existing files.....

If salida.txt does not exist
you can create the file by using

print "== if the file doesn't exist, create one =="
if os.path.exists('salida.txt'):
    print "File exists"
else:
    print "Creating the salida.txt-file"
    my_file = open("salida.txt", 'w')
    my_file.write("I'm the first line of the file!" +"\n")
    my_file.write("I'm the second line."+"\n")
    my_file.write("Third line here, boss."+"\n")
    my_file.close()

Now you can read the file with

my_file = open("salida.txt","r")
print my_file.readline()
print my_file.readline()
print my_file.readline()
my_file.close()

http://stackoverflow.com/questions/1466000/python-open-built-in-function-difference-between-modes-a-a-w-w-and-r


#3

Type something in the output.txt tab and click "save & submit" it will work.


#4

thank you i typed and the code worked