← Back to Classes
Question 493
Add A Book To The Library
Add A Book To The Library
A Library is not a kind of Book; it HAS a list of them in the attribute books. Write the body of add_book so it appends the given book object to that list. Do NOT write a main block or any top-level test code; the tests construct the class. Input: two lines, each a title, which the tests turn into Book objects and add in order; they then print how many books the library holds and each title on its own line.
Expected Output:
2 Dune Emma
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Classes
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.