Advertisement
jumboframe

Untitled

Jul 17th, 2021
786
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1.  
  2.     def count_objects(self, object_type, objects):
  3.         return [object_by_type for object_by_type in objects if object_by_type.__class__.__name__ == object_type]
  4.  
  5.     def animals_status(self):
  6.         res = f"You have {len(self.animals)} animals"
  7.         for animal_type in ["Lion", "Tiger", "Cheetah"]:
  8.             animal = self.count_objects(animal_type, self.animals)
  9.             res += f"\n----- {len(animal)} {animal_type}s:\n"
  10.             res += "\n".join([animal_t.__repr__() for animal_t in animal])
  11.         return res
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement