Write a python program, that takes three strings as input parameters. The function reads all the data from the inFile (1st input parameter) and writes data to the outFile (2nd input parameter) as described below. Each line in the input file represents a pet record and has the following format. name, breed, age where name and breed are strings, and age is an integer value. Your function must find the oldest pet of a given breed (3rd input parameter) from the inFile and write the following information to the outFile. breed, total records of this breed name of the oldest pet, age of the oldest pet Note that outFile must only have these two lines of information. Suppose, inFile contains the following data: shadow, longhair, 3 poshi, bangal, 5 mikus, longhair, 4 tigger, calico, 9 If you call this function with breed = "longhair", then the following must be written in the outFile: longhair, 2 mikus, 4 Your function must return True if both reading and writing were successful, and False otherwise. This function should properly handle all exceptions so that your program does NOT crash. You do not have to write a main() function for this program.
Write a python
Each line in the input file represents a pet record and has the following format.
name, breed, age
where name and breed are strings, and age is an integer value.
Your function must find the oldest pet of a given breed (3rd input parameter) from the inFile and write the following information to the outFile.
breed, total records of this breed
name of the oldest pet, age of the oldest pet
Note that outFile must only have these two lines of information.
Suppose, inFile contains the following data:
shadow, longhair, 3
poshi, bangal, 5
mikus, longhair, 4
tigger, calico, 9
If you call this function with breed = "longhair", then the following must be written in the outFile:
longhair, 2
mikus, 4
Your function must return True if both reading and writing were successful, and False otherwise. This function should properly handle all exceptions so that your program does NOT crash.
You do not have to write a main() function for this program.
Step by step
Solved in 4 steps with 2 images