a bit of a silly question. I am trying to insert (prepend) multiple text files (apple
, banana
, pear
) into a main text file (fruitsalad.txt
).
How do a make this more concise? (PS there is more fruit than what I am showing!)
input01 = path_include + 'apple.txt'
input02 = path_include + 'banana.txt'
input03 = path_include + 'pear.txt'
prepend01 = open(input01,'r').read()
prepend02 = open(input02,'r').read()
prepend03 = open(input03,'r').read()
open(fruitsalad_filepath, 'r+').write(prepend01+prepend02+prepend03 + open(fruitsalad_filepath).read())