Question: Answer to be coded in python using lists and while/for loops Write a function named longest. This function will accept two parameters, each of which

Answer to be coded in python using lists and while/for loops

Answer to be coded in python using lists and while/for loops Write

Write a function named longest. This function will accept two parameters, each of which will be lists on strings (not necessarily of the same length). This function should determine if the first or the second argument has a greater number of total characters in all of the elements. For each list, go through each element and sum the lengths of all the strings. Whichever sum is greater is the "longer" list. Return 1 if the first is longer, 2 if the second is longer, and 3 for a tie. For example, these tests: 11 = ['this is a string!"] 12= ['a', 'b', 'c'] print(longest(11, 12)) 11 = ['one", .two", 'three.] 12- ["four', 'five', 'six'] print(longest(11, 12)) 11-Joe", "Reed"] print(longest(11, 12)) Should produce: You might want to create a helper function, which just computes the character-length of a single list

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!