Question: Python must work for all cases not just test cases zoo keeper Parameters: a list of tuples containing the type of the animal (string), the
zoo keeper Parameters: a list of tuples containing the type of the animal (string), the specific species (string), and the total count (int). Assume valid arguments will always be passed in. Returns: A dictionary containing the types of the animals as keys and a dictionary with the species and the number of each animal as the value Description: As a zoo keeper you need to take a head count of how much of each animal is in the zoo. Write a function called zoo_keeper that takes in a list of tuples with the animal's type, the animal's species and the number of each animal. You should return a dictionary with the animal's type as a key and a dictionary with the species and the number of each animal as its value. If an animal's type or species appears more than once, you should add the population to the existing animal. All tuples will be completely lower cased. Test cases list ('mammal', 'doge', 4), ('reptile, 'python', 37), ('bird, chicken nugget', 8), ('mammal', 'clifford', 2), (reptile''python' 3), ('bird', 'eagle',1), 'mammal', 'harambe, e)] >>> zoo_ population2 zoo_ keeper(list2) >print (zoo_population2) ('mammal': doge': 4, 'clifford: 2, 'harambe': e), Ireptile': ('python': 4, bird': ('chicken nugget': 8, 'eagle': 1)) beardeddragon, 3),fish', nemo, 1), 'reptile, 'beardeddragon, 2), ('mammal', 'stuartlittle,5), ('fish', goldfish, 30) >>>zoo_ population1 zoo_keeper(list1) > print (zoo populationi) 'mammal':'mickeymouse': 100, stuartlittle 5), reptile ('beardeddragon': 5)fish': C'nemo': 1, goldfish: 30))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
