I have this list, all the elements are float. Now i want to join them together with certain format for example exponent notation, so that I can print them out in one line.

So I did this

for line in fileinput.input(filename):
        old_line = line.split()
        new_line = [float(s) for s in old_line]
        # some calculation
        line_jn = ' '.join(['%15E' % (x for x in new_line)])
        print >> fOUT, line_jn

I got the error msg:
line_jn = ' '.join()
TypeError: float argument required

But all the items in new_line are float, so x is float, where does it need float argument?

Alternatively, I don't have to do it this way, I can just print out the elements in the list new_line in one line with exponent notation. I know stdout.write can do that, but I am printing them to a file. Is there a way to do it?

Thanks in advance.

Try something like this ...

new_line = [1.2, 2.4, 1234.5]

line_jn = ' '.join(['%15E' % x for x in new_line])

print(line_jn)  # 1.200000E+00    2.400000E+00    1.234500E+03