Answer to Question #261667 in Python for Jac

Question #261667

Create a library management system wherein any library member should be able to search books by their title, author, subject category as well by the publication date.


1
Expert's answer
2021-11-05T17:22:05-0400
search_for = input("Type the keyword: ").lower()
# Python3 code here creating class
class books: 
    def __init__(self, name, author, publication, subject): 
        self.name = name.lower() 
        self.author = author.lower()
        self.publication = publication
        self.subject = subject.lower()
   
# creating list       
list = []
  
# appending instances to list 
list.append( books("The Judge's List", "John Grisham", "10/2021", "fiction"))
list.append( books('The Wish', "Nicolas Sparks", "09/2021", "drama"))


result = []  
for obj in list:
      if search_for in obj.name:
        result.append(obj.name)
      if search_for in obj.author:
        result.append(obj.name)
      if search_for in obj.subject:
        result.append(obj.name)
if len(result) < 1:
  print("Not found")
else:
  print(result)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS