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