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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started