Question: Write a program called p2.py that contains a function called less_than_age () that takes a filename (string) and an int x as input parameters.
Write a program called p2.py that contains a function called less_than_age () that takes a filename (string) and an int x as input parameters. The file contains a list of some names and ages (comma-separated) like the sample file above. This function should return the names of all the animals with age less than x in a list. Test your function using the main function (don't forget the main guard). Sample output: >>> less_than_age ("samplefile_t8.txt", 4) returns ["wombat", "koala", "dingo", "kookaburra"]
Step by Step Solution
3.46 Rating (169 Votes )
There are 3 Steps involved in it
Below is a sample implementation of the lessthanage function in a Python pr... View full answer
Get step-by-step solutions from verified subject matter experts
