Prototype: implement available_copies(copies, title). Input copies is a list of (copy_id, title, available) tuples with unique copy identifiers and boolean availability. Assume valid inputs. Return a fresh lexicographically sorted list of available identifiers whose title equals the supplied case-sensitive title. Do not modify input; an unknown title returns [].

Final: implement Library(copies), where copies is a list of (copy_id, title) pairs. Copy identifiers must be unique nonempty strings; titles and member identifiers are nonempty strings. Invalid constructor or method identifiers raise ValueError before mutation. Empty catalog is valid. Title strings are the title identity for this exercise; matching is exact and case-sensitive.

borrow(member_id, title) returns the smallest available copy identifier, or None if the title is unknown or all its copies are loaned. If that member already holds this title, raise ValueError without changing any loan. return_copy(copy_id, member_id) returns True after releasing the member's loan; return False for an unknown or unloaned copy. If a different member holds it, raise ValueError without changing state. available(title) returns a fresh sorted list of free copy identifiers. loans() returns a fresh list of fresh dictionaries with keys copy_id, title, and member_id, sorted by copy identifier. Copy constructor input and keep instances independent. Do not add due dates or catalog editing.

Drag or use the arrow keys to resize. Home collapses the question; End collapses the editor. Enter or double-click resets the split.
Loading editor…
No results yet.

Complete the starter code, then run the checks.
Results and errors will appear here.