Question: language is python File Reading and Writing Write a function mergeLines that takes no arguments and rewrites an input file called mydata.txt into an output

 language is python File Reading and Writing Write a function mergeLines

language is python

File Reading and Writing Write a function mergeLines that takes no arguments and rewrites an input file called mydata.txt into an output file newdata.txt Each pair of lines in mydata.txt need to be merged in newdata.txt. For example, if mydata.txt contains the following text: 1 a aaa bbb. c dddddd 2 e f 34.12 gggggg g then, newdata .txt is to contain 1 a aaabbb. Cdddddd 2 e f 34.12 gggggg g Note that if the file contains odd number of lines, the last line is not merged with any other line but simply rewritten to the output file. You are to assume you will be dealing with the files with the exact names mentioned in this description but you do not know the actual contents: the length and contents of each line or the number of lines to process. The example above is just to illustrate what the function is to do. You may assume that the input file will have at least one line of text

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!