FileIO problem

Layin'_Low stud0505 at yahoo.com
Wed Aug 24 02:53:04 EDT 2005


i'm havin a problem with this simple program. i need the output of this
loop to be written to a file but i dont know how to do it!! this is
what i have right now:

gclas = raw_input("What is the class:")
count = 0
while count != 1000:
    count = count + 1
    print "Admin forceclass " , count , gclas

i know the IO script. i tried calling it a function, but i got an error
that says  i cant call funtions for writing:

gclas = raw_input("What is the class:")
def Princlas():
    count = 0
    while count != 1000:
        count = count + 1
        print "Admin forceclass " , count , gclas
#asks for file name
a = raw_input("What is new file name:")
out_file = open(a,"w")
#this is the input of text
out_file.write(Princlas)
out_file.close()

i know i need to get it to a string but i dont know how?Any solution or
help i s more that welcome




More information about the Python-list mailing list