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 () 

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

1 Expert Approved Answer
Step: 1 Unlock

Below is a sample implementation of the lessthanage function in a Python pr... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!