I have to write a table called tempconv.txt, the table should have temps from -300-212 fah and the cel equivalents with steps of 10 or 20, presented in 2 columns.I keep getting a syntax error. I think i am having trouble with the opening and closing of the file. Thanks for any help.

def feh():
    outfile = open("tempconv.txt","w")
    outfile.write ("%10s%10s\n"%(feh,"cel"))
for i in range ( -300,240,120):
                   counterCelsius = (i -32) / 1.8
                   outfile.write("%10.3f %10.3f\n" %(i,convertCelsius)
    outfile.close (

indention of lin 4 is of and are you realy looping in steps of 120?

check your indentation from for loop to end.

Also why not do things the easy way.??

;)

steps of 20

what is the easy way

I am still getting a systex error when closing the file

I am still getting a systex error when closing the file

We can't really guess what that is. Post the entire error message. As a general rule, check that line of code and the previous for the same number of open and closing parens. If there is a paren error on the previous line, the interpreter sees the next line as a continuation line. Also, you close the file, but never open it, so that could be one of the errors.

what is the easy way

Pseudocode:

with open(...) as myfile:
     generator -> formatter -> join the line -> join the lines -> myfile.write argument
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.