Library Catalogue
Library Catalogue
Write two classes from scratch. Book(title, author, pages) stores the two strings and the whole number of pages. Library() creates an empty list attribute books; add_book(book) appends a Book; titles_by(author) returns a list of the titles whose author attribute matches, in the order they were added; total_pages() returns the sum of every page count; longest() returns the title of the book with the most pages. Do NOT write a main block or any top-level test code; the tests construct the class. Input: four lines: a title, an author and a page count for one extra book, then an author to look up. The tests build a library with Dune (Frank Herbert, 412), Emma (Jane Austen, 320) and Persuasion (Jane Austen, 250), add the extra book, print each title titles_by returns on its own line, then print the total pages and the longest title.
Expected Output:
Emma Persuasion 1862 Middlemarch
= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...