I want to read two unequal size python lists and write to the files. I can do this by repeating for-loops
with open(folder/'{}_matched_1_ids.txt'.format(f_1_latest[7:11]), 'a+') as matched_1_IDWriter, \
open(folder/'{}_matched_2_ids.txt'.format(f_1_latest[7:11]), 'a+') as matched_2_IDWriter:
for item in matched_1:
matched_1Writer.write("{},".format(item))
for item in matched_2:
matched_2Writer.write('{},'.format(item))
Instead of using 3 different for-loops, I could use itertools.zip_longest() with fillable option to none or "". But, I need nothing to fill (IGNORE) when loop's one iterator encounters nothing in the list to iterate over compared to other iterators. Is there a way to do that? I saw a similar pattern here but, didn't able to reproduce the solution in creating files.