1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
SOVA2 [1]
3 years ago
10

Design the program that reads two files and compares their contents. The program calls a method that reads the file one line at

a time. If the lines are the same the program skips the line. If the lines are different then the program prints the line number followed by the different lines from each file.
Computers and Technology
1 answer:
Advocard [28]3 years ago
5 0

Answer:

file1 = []

file2 = []

fileone = "lyric1.txt"

filetwo = "lyric2.txt"

def linereader( myfile, mylist):

   for line in open(myfile, "r") as file:

       line_read = readlines( line)

       mylist.append( line_read)

   file.close()

linereader( fileone, file1)

linereader( filetwo, file2)

# Assuming both files have same number of lines.

for index, item in enumerate(zip(file1, file2)):

   if item[0] != item[1]:

       print( index + 1, item)

Explanation:

The python code compares two files and returns the number and the lines from both files that do not match. The source code opens the files lyric1.txt and lyric2.txt reading each lines to different lists which are iterated to compare its items returning the number of the line and the unequal lines.

You might be interested in
In what four ways do we commonly respond?
Gnoma [55]

Answer:

A

Explanation:

4 0
3 years ago
What is the importance of technology in your life?Explain.
Ghella [55]

technology has been very important in my life because, it helps me with my daily struggles, helps with stress (social media), makes everything easier, also creates a more efficient way of learning and much more.

although this should be answered with your own thoughts and opinions, I provided mine if in any case that it helps

8 0
3 years ago
PLEASE HELP!!!!!!!!!!
SCORPION-xisa [38]
I don’t know if u tried this yet but maybe acetone can help or vinegar?
8 0
3 years ago
Read 2 more answers
When might an lcd monitor experience distorted geometry?
horsena [70]

The time when an LCD monitor is experiencing distorted geometry is when there is a presence of the screen into having a display that is not set on the resolution that is supposed to be in native, this is indicative that it is experiencing distorted geometry.

7 0
4 years ago
Which part of the computer provides access to internet ?
Doss [256]
The Modem is the correct answer
8 0
4 years ago
Read 2 more answers
Other questions:
  • Web sites use _____ to track users while they are on the site.
    9·1 answer
  • How far from the bullet is text indented
    6·2 answers
  • How can you ensure that your web pages are compliant with a w3c standard?
    9·1 answer
  • In case of an emergency, once you or someone already on the scene has contacted 9-1-1, the next thing to do is: A) Move them to
    9·2 answers
  • PLEASE HELP. I’ll mark you BRAINLIST <br> Please read the comment under this question
    9·1 answer
  • ⦁ ¿Cuáles son los recursos naturales que se utilizan en tu comunidad para generar energía eléctrica?
    14·1 answer
  • True or false Encryption prevents hackers from hacking data?
    8·1 answer
  • Binary is used to store what on a computer?<br> •Data<br> •Dates<br> •Address
    13·2 answers
  • A _____ shows how data moves through an information system but does not show program logic or processing steps.
    6·1 answer
  • An array called numbers contains 35 valid integer numbers. Determine and display how many of these values are greater than the a
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!