Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Catalogue:
- def __init__(self, name: str):
- self.name = name
- self.products = []
- def add_product(self, product: str):
- self.products.append(product)
- def get_by_letter(self, letter: str):
- stuff = [x for x in self.products if x.startswith(letter)]
- return stuff
- def __repr__(self):
- result = ''
- result += f"Items in the {self.name} catalogue:\n"
- result += '\n'.join(sorted(self.products))
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement