I have an Input.txt file , output.txt file, and my .py file, i need to read all text from input file and add it at the START of output file.How can i do this? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I have an Input.txt file , output.txt file, and my .py file, i need to read all text from input file and add it at the START of output file.How can i do this?

Can u help me?

31st Aug 2016, 4:56 AM
Leshark
Leshark - avatar
1 Answer
+ 2
open input.txt, read it's content to variable (for ex., txt1). then do the same for output.txt, read it to txt2. then close both files, open output.txt for writing and write txt1+txt2 to it. how to read/write files you can find in this tutorial.
31st Aug 2016, 5:38 AM
Demeth
Demeth - avatar