Question: How to Correct my code? With details. thank you. The following expressions (already in the coding box) create a file named text1.txt with the following

How to Correct my code? With details. thank you.

How to Correct my code? With details. thank you. The following expressions

(already in the coding box) create a file named text1.txt with the

The following expressions (already in the coding box) create a file named text1.txt with the following content: Do you love Python programming? No, I don't. . Please write the code that reads the content from file text1.txt, and writes the content to file named text2.txt with the sentence "No, I don't" changed to "Yes, I do.". For example: \begin{tabular}{l|l} 1 & with open('text1.txt', 'w') as test1_file: \\ 2 & test1_file.write("Do you love Python programming? " ") \\ 3 & test1_file.write("No, I don't.") \\ 4 & \\ 5 & file1 = open('text1.txt', 'r') \\ 6 & lines = file1.readlines() \\ 7 & file2 = open("text2.txt", 'w') \\ 8 & \\ 9v & for line in lines: \\ 10v & if line == "No, I don't." : \\ 11 & file2.write(line) \\ 12v & else: \\ 13 & file2.write("Yes, I do.") \\ 14 & file2.close() \\ 15 & \\ 16 & with open('text2.txt', 'r') as file2: \\ 17 & data2 = file2.read() \\ 19 & \\ 20 & print(data2) \end{tabular} Check Your code must pass all tests to earn any marks. Try again. Show differences

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!