Question: Define the get_longest_name() function which is passed a list of strings as a parameter. The function returns the word in the list which has the

Define the get_longest_name() function which is passed a list of strings as a parameter. The function returns the word in the list which has the most characters (i.e., the longest word) BUT only words with six or more characters are considered. If two or more words in the list have the same number of characters as the longest word, the function should return the first word from the start of the list which has the most characters. If the parameter list is empty or if there are no words in the list with six of more characters, the function should return the empty string. For example, the following code:

Test

print("1.", get_longest_name(["Candide", "Jessie", "Kath", "Amity", "Raeanne"])) print("2.", get_longest_name(["Josephine", "Jessie", "Penelope", "Jin", "Rosamunda", "Annabelle"])) print("3.", get_longest_name(["Alan", "Jess", "Amity", "Rosalie", "Raeanne"])) print("4. ", "***", get_longest_name(["Jo", "Jai", "Jen", "Jing", "Joey", "Jess"]), "***", sep = "") print("5. ", "***", get_longest_name([]), "***", sep = "") print("6.", "***" + get_longest_name([""]) + "***") 

Expected

print("1.", get_longest_name(["Candide", "Jessie", "Kath", "Amity", "Raeanne"])) print("2.", get_longest_name(["Josephine", "Jessie", "Penelope", "Jin", "Rosamunda", "Annabelle"])) print("3.", get_longest_name(["Alan", "Jess", "Amity", "Rosalie", "Raeanne"])) print("4. ", "***", get_longest_name(["Jo", "Jai", "Jen", "Jing", "Joey", "Jess"]), "***", sep = "") print("5. ", "***", get_longest_name([]), "***", sep = "") print("6.", "***" + get_longest_name([""]) + "***") 

Expected

1. Candide 2. Josephine 3. Rosalie 4. ****** 5. ****** 6. ****** 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!