Python: Takes a list of words and returns the length of the longest one
Find longest word in a list.
Write a Python function that takes a list of words and return the longest word and the length of the longest one.
Sample Solution:
Python Code:
Sample Output:
Longest word: Exercises Length of the longest word: 9
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Python program to iterate through a list of words and return the longest word along with its length using a loop.
- Write a Python program to use the max() function with a custom key to determine the longest word in a list.
- Write a Python program to sort a list of words by length and output the last element as the longest word.
- Write a Python program to implement a recursive function that finds the longest word in a list of words.
Go to:
Previous: Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'bad' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.
Next: Write a Python program to remove the nth index character from a nonempty string.
Python Code Editor:
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.