Question: class Library(): # add your code here def __init__self(): self.books = [] self.tornPageTolerance = 5 def addBook(self,book): self.books.append(book) return (none) def findBooksBy(self,author): for auth_attr in
class Library():
# add your code here
def __init__self():
self.books = []
self.tornPageTolerance = 5
def addBook(self,book):
self.books.append(book)
return (none)
def findBooksBy(self,author):
for auth_attr in self.books:
if auth_attr == auth_attr.author:
return
results in:
7 def addBook(self,book): ----> 8 self.books.append(book) 9 return (none) 10 AttributeError: 'Library' object has no attribute 'books'
Navigate back up to the cell containing the Library class and add the methods below. After you add the methods make sure you run the cell.
- addBook
- Accepts the parameterbookwhich is an instance of Book
- Appendbooktoself.books
- Returns nothing
- findBooksBy
- Accepts the string formal parameter author
- Searchs the listself.books
- Returns a list of all books whose author attribute matches the author parameter.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
