Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def count_objects(self, object_type, objects):
- return [object_by_type for object_by_type in objects if object_by_type.__class__.__name__ == object_type]
- def animals_status(self):
- res = f"You have {len(self.animals)} animals"
- for animal_type in ["Lion", "Tiger", "Cheetah"]:
- animal = self.count_objects(animal_type, self.animals)
- res += f"\n----- {len(animal)} {animal_type}s:\n"
- res += "\n".join([animal_t.__repr__() for animal_t in animal])
- return res
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement