Question: 3. Write a function longest(L) which examines the argument list L and returns the longest string. You can assume all of the elements of


3. Write a function longest(L) which examines the argument list L and

3. Write a function longest(L) which examines the argument list L and returns the longest string. You can assume all of the elements of the list L are strings, and that the list is not empty. Use the approach where there is a variable largestyet which is initialized to the first element of L. Then go through the rest of the elements and update largestyet whenever you encounter a longer string. For example" longest (['blue', 'red', 'the white house', 'green']) would return 'the white house'.

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 Programming Questions!