Ask Question
15 March, 18:20

Suppose the Bookstore is processing an input file containing the titles of books in order to remove duplicates from their list. Write a program that reads all of the titles from an input file called bookTitles. txt and writes them to an output file called noDuplicates. txt. When complete, the output files should contain all unique titles found in the input file.

+3
Answers (1)
  1. 15 March, 18:33
    0
    books = []

    fp = open ("bookTitles. txt")

    for line in fp. readlines ():

    title = line. strip ()

    if title not in books:

    books. append (title)

    fp. close ()

    fout = open ("noDuplicates. txt", "w")

    for title in books:

    print (tile, file=fout)

    fout. close ()

    except FileNotFoundError:

    print ("Unable to open bookTitles. txt")
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Suppose the Bookstore is processing an input file containing the titles of books in order to remove duplicates from their list. Write a ...” in 📗 Engineering if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers