Medium
Count Objects per Class
class Animal keeps a class-level dictionary counting how many objects of each class were created (use type(self).__name__ in __init__). Dog and Cat inherit from it. Read class names and create the objects, then print each class name and count in alphabetical order.Input
Names: Animal, Dog or Cat.
Output
Lines.
Sample 1
Input
Dog Cat Dog
Output
Cat 1 Dog 2
Sample 2
Input
Animal
Output
Animal 1
Output appears here