Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions

Question

LO4 Specify how to design a training program for adult learners.

Answered: 1 week ago