Advertisement
eNeRGy90

Untitled

Feb 15th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. class Book:
  2.     def __init__(self, title, author, price, chapters):
  3.         self.title = title
  4.         self.author = author
  5.         self.price = float(price)
  6.         self.chapters = chapters
  7.  
  8. books = []
  9.  
  10. while True:
  11.     text = input()
  12.     if text == "on work":
  13.         break
  14.  
  15.     text = text.split(" -> ")
  16.     f_half = text[0].split()
  17.     if len(f_half) > 2:
  18.         books.append(Book(f_half[0], f_half[1], f_half[2], text[1].split(", ")))
  19. sold_books = []
  20.  
  21. while True:
  22.     text = input()
  23.     if text == "end work":
  24.         break
  25.  
  26.     for book in books:
  27.         if book.title == text:
  28.             sold_books.append(book)
  29.         else:
  30.             print(f"No such book here")
  31.  
  32.  
  33. print(sold_books)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement