Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Zoo:
- __animals = 0
- def __init__(self, name):
- self.name = name
- self.mammals = []
- self.fishes = []
- self.birds = []
- def add_animals(self, species, name):
- if species == "mammal":
- self.mammals.append(name)
- elif species == "fish":
- self.fishes.append(name)
- elif species == "bird":
- self.birds.append(name)
- self.__animals += 1
- def get_info(self, species):
- result = ''
- if species == 'mammal':
- result += f"Mammals in {self.name}: {', '.join(self.mammals)}\n"
- elif species == 'fish':
- result += f"Fishes in {self.name}: {', '.join(self.fishes)}\n"
- elif species == 'bird':
- result += f"Birds in {self.name}: {', '.join(self.birds)}\n"
- result += f"Total animals: {self.__animals}"
- return result
- zoo_name = input()
- zoo = Zoo(zoo_name)
- count = int(input())
- for _ in range(count):
- animal = input().split(" ")
- species, name = animal[0], animal[1]
- zoo.add_animals(species, name)
- info = input()
- print(zoo.get_info(info))
Add Comment
Please, Sign In to add comment