Function Name: class Trip() Parameters: friendList (list) Returns: nameList (list) Description: Your TAs have decided to
Posted: Mon Jun 06, 2022 1:50 pm
Function Name: class Trip() Parameters: friendList (list) Returns: nameList (list) Description: Your TAs have decided to take the whole CS 1301 class on a field trip and you can bring your friends! But they dont have the money to pay for everyone. You are provided with a list containing sublists. Each sublist includes the name of your friend (str), their age (int), and how much money they are bringing (float ). The elements of the sublists are in no particular order, and some friends may be repeated, appearing in multiple sublists. From this jumbled list of lists, you wish to create a list of just your friends' names. Write a function that takes in a list of lists as de- scribed, and returns a list of the names of your friends that are coming on the trip, with no names repeated, and sorted in alphabetical order. Hint: The .sort() method or sorted() function will be useful here. >>> class Trip ([["Kathleen", 26, 40.0], [19, "Jada", 52.0], ["Kathleen", 26, 40.0], ["Samuel", 22, 36.0], [22, 68.0, "Annie"], [21, 70.0, "Arvin"], [21, "Cooper", 92.0], ["Leana", 22, 36.0], [21, 92.0, "Cooper"]]) ['Annie', 'Arvin', 'Cooper', 'Jada', 'Kathleen', 'Leana', 'Samuel'] >>> classTrip ([[22, "Rocky", 103.0], ["Felix", 19.0, 20], ["Elizabeth", 11.0, 65], [15.0, 20, "Astrid"], [23, "Elizabeth", 88.0], [72.0, 21, "Felix"]]) ['Astrid', 'Elizabeth', 'Felix', 'Rocky']