A custom constructor in Python is written as an instance method named __init__
. (The double
underscores on either side of a name are Python's convention for marking something as public, but special in some
way.) For example:
class Book(object):
def __init__(self, comment):
print(f'Created a book with the comment {comment}')
prints a line whenever a book object is created. The call to the constructor would look like this:
a_book = Book('(400 pages)')
Fill in the placeholders so that the program prints the text
Created a library named "Public Library".