Complete the Library Hierarchy
Book and EBook are provided complete and working, each with its own describe(). Library is incomplete - add its three missing methods:
add_book(self, book)- appendsbooktoself.books.find_available(self)- returns a list of every book inself.booksthat is available, treating any item without anis_availableattribute at all as available by default (usegetattr(book, "is_available", True)).describe_all(self)- returns a list ofdescribe()strings, one per book, in order.
Read a library name, then a book's details, then an ebook's details, build the library, add both, borrow the first book directly, then print every line from describe_all() followed by the length of find_available() - proving your Library correctly handles two genuinely different classes polymorphically.
main.py
Loading editor…
Console
Run your code to see output here.