Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part 2 Lnai 8725

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448505, 978-3662448502

More Books

Students also viewed these Databases questions