How to list to column file

k = [74.33333333333333, 66.66666666666667, 42.666666666666664, 60.333333333333336, 53.333333333333336] with open('D:\\py\\4.txt', 'w') as ouf: for j in k: ouf.write(str(j)\n) 

Without \n prints everything on one line, appends \n and - SyntaxError: invalid syntax

  • Mark the question as correct if it solved your problem. - approximatenumber

1 answer 1

Do this:

 ouf.write(str(j)+'\n') # ΠΊ ΠΊΠΎΠ½Ρ†Ρƒ Π²Ρ‹Π²ΠΎΠ΄ΠΈΠΌΠΎΠΉ строки прикрСпляСтся символ '\n' 

Or so (if you have python3):

 print(j, file=ouf) # print ΠΏΠΎ-ΡƒΠΌΠΎΠ»Ρ‡Π°Π½ΠΈΡŽ Π²Ρ‹Π²ΠΎΠ΄ΠΈΡ‚ с ΠΏΠ΅Ρ€Π΅Π²ΠΎΠ΄ΠΎΠΌ строки 
  • It helped, senks. - Lita Litar
  • one
    from __future__ import print_function allows using the print function both on Python 2 and 3. - jfs