CJCoding With Joseph
15free / daySign inCreate account

Find A Title In The Library

The Book class is given. Write the whole Library class: the constructor creates an empty list attribute books; add_book(book) appends a Book; has_title(title) loops over the books and returns True as soon as one has a matching title attribute, or False after the loop if none does. Do NOT write a main block or any top-level test code; the tests construct the class. Input: one line, a title, which the tests read and look up with has_title in a library holding Dune, Emma and Beloved before printing the result.

Expected Output:

True

= newline. The output ends with a newline — print one after the last line.

Hints3 available
Topics:
Classes
📥 Auto-Input:
Emma\n
This input is automatically fed to your program's stdin
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.