Question: Write a function concatenate_files(filename1, filename2,new_filename) that concatenates the text from two source files such that the text from the file named by argument filename2follows the

Write a function concatenate_files(filename1, filename2,new_filename) that concatenates the text from two source files such that the text from the file named by argument filename2follows the text from filename1. The concatenated text is written to a new file with the name given by new_filename. Your function must not return anything.

We have provided sample input files named part1.txt and part2.txt containing a portion of the text from the novel Alice in Wonderland to test your function.

My incomplete CODING:

def concatenate_files(filename1, filename2, new_filename): string1 = open(filename1, 'r').read() string2 = open(filename2, 'r').read() strings = string1, string2 f = open(new_filename, 'a') for string in strings: f.write(string, 'a') string += 1 f.close()

Please correct my code according to this question and tell me which steps i did wrongly, please :) thank you !

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!