Aim it to concatenate multiple lists to one list within a for loop. At the moment the output prints map objects rather than all the content merged in one list.
Directory

Content of each sample file
aa - http://cc
bb - http://bb
cc - http://aa
aa - aa - http://cc
bb - bb - http://bb
cc - cc - http://aa
aa - aa - aa - http://cc
bb - bb - bb - http://bb
cc - cc - cc - http://aa
Code
import os
cwd = os.getcwd()
for fn in os.listdir(cwd):
with open(fn, "r+") as f, open(cwd + "\\all.txt", "r+") as f2:
lines = f.readlines()
my_list = [fn + " - " + x for x in lines]
concatenated_list = map(" ".join, zip(my_list))
print(concatenated_list)
Outcome
Current
C:\case.py
<map object at 0x0000000002CB7BE0>
<map object at 0x0000000002CB7B00>
<map object at 0x0000000002CB79E8>
<map object at 0x0000000002CB7E10>
<map object at 0x0000000002CB7A90>
<map object at 0x0000000002CB78D0>
Expected
C:\Users\r\Desktop\test>C:\Users\r\Desktop\case.py
[]
['sample.txt - aa - http://cc\n', 'sample.txt - bb - http://bb\n', 'sample.txt -
cc - http://aa\n', 'sample.txt - aa - aa - http://cc\n', 'sample.txt - bb - bb
- http://bb\n', 'sample.txt - cc - cc - http://aa\n', 'sample.txt - aa - aa - aa
- http://cc\n', 'sample.txt - bb - bb - bb - http://bb\n', 'sample.txt - cc - c
c - cc - http://aa\n','sample2.txt - aa - http://cc\n', 'sample2.txt - bb - http://bb\n', 'sample2.tx
t - cc - http://aa\n', 'sample2.txt - aa - aa - http://cc\n', 'sample2.txt - bb
- bb - http://bb\n', 'sample2.txt - cc - cc - http://aa\n', 'sample2.txt - aa -
aa - aa - http://cc\n', 'sample2.txt - bb - bb - bb - http://bb\n', 'sample2.txt
- cc - cc - cc - http://aa\n'...
zip,joinandmapcalls are all completely unnecessary. Get rid of them all and just useprint(my_list)and you'll get the desired result.