Question: Task 1 : Write a script named dif.py . This script should prompt the user for the names of two text files and compare the
Task : Write a script named
dif.py This script should prompt the user for the names of two text files and compare the contents of the
two files to see if they are the same. If they are, the script should simply output "Yes". If they are not, the script should output No
followed by the first lines of each file that differ from each other. The input loop should read and compare lines from each file. The loop
should break as soon as a pair of different lines is found. LO:
My code:
def comparefilesfile file:
Compare the contents of the two files.
with openfiler as f:
with openfiler as f:
for line line in zipf f:
if line line:
printNo
printline
printline
return
printYes
def main:
Test function
file inputEnter the first file name:
file inputEnter the second file name:
comparefilesfile file
if namemain:
main
exit
Test Feedback:
Status: PASSED!
Check:
Test: Program outputs correct values for filetxt and filetxt
Reason: 'Yes' was found in the program's output. None
Timestamp: ::
Status: FAILED!
Check:
Test: Program outputs correct values when user inputs 'goodbye'
Reason: Unable to find No and mismatched lines' in the program's output.
Enter the name of the first file: Enter the name of the second file: No
hello from filetxt
Max from filetxt
Error : AssertionError
Timestamp: ::
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
