[Solved] How do you read a file then output the integers as ‘1’ in txt


This should solve your problem.

Input file:

1234
5678

Code:

with open('a.txt') as if1:
    for everyline in if1:
        everylineactual = everyline.rstrip('\n')
        everylineactual = "','".join(everylineactual)
        everylineactual = f"'{everylineactual}'\n"
        with open('b.txt','a') as of:
            of.write(everylineactual)

Output file:

'1','2','3','4'
'5','6','7','8'

0

solved How do you read a file then output the integers as ‘1’ in txt