+ 2

Python: list with write line in new file

Hello all, I have a code with some lists. But when I save it in TXT the result have [ ] in each line How to remove them before saving? Code: for elem in line_arr: line_arr_items += 1 line_check = re.match( "\"\d", line ) if (line_arr_items == 12): if line_check: # make good line line_new = str(line_arr[:5] + line_arr[8:10]) outfile.write( line_new + '\n' ) if (line_arr_items == 10): if line_check: line_new=str(line_arr[0:10]) outfile.write( line_new + '\n' ) Result: ['"03/01/17 11:04:00"', '""', '"49s"', '"052648227"', '"331"', '""', '""', '""', '"0"', '"$0.1222"'] ['"03/01/17 11:04:00"', '""', '"49s"', '"052648227"', '"331"', '"0"', '"$0.1222"']

15th Nov 2017, 10:47 AM
Radostina Stefanova
Radostina Stefanova - avatar
1 Answer
+ 3
print(*name_it_your_list) -use * (star before name of your list)
15th Nov 2017, 11:16 AM
yuri