Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started