Python: Find the even-length words and sort them by length
Sort Even-Length Words
Write a Python program to find even-length words from a given list of words and sort them by length.
Input: ['Red', 'Black', 'White', 'Green', 'Pink', 'Orange'] Output: ['Pink', 'Orange'] Input: ['The', 'worm', 'ate', 'a', 'bird', 'imagine', 'that', '!', 'Absurd', '!!'] Output: ['!!', 'bird', 'that', 'worm', 'Absurd']
Visual Presentation:

Sample Solution:
Python Code:
Sample Output:
Original list of words: ['Red', 'Black', 'White', 'Green', 'Pink', 'Orange'] Find the even-length words and sort them by length in the said list of words: ['Pink', 'Orange'] Original list of words: ['The', 'worm', 'ate', 'a', 'bird', 'imagine', 'that', '!', 'Absurd', '!!'] Find the even-length words and sort them by length in the said list of words: ['!!', 'bird', 'that', 'worm', 'Absurd']
Flowchart:

For more Practice: Solve these Related Problems:
- Write a Python program to extract even-length words from a list and sort them by their length in ascending order.
- Write a Python program to filter words with even number of characters from a list and then order them based on length.
- Write a Python program to use list comprehension to select even-length words and then sort the result alphabetically.
- Write a Python program to identify and sort even-length words by both their length and lexicographical order.
Go to:
Previous: Find the h-index, the largest positive number h such that h occurs in the sequence at least h times.
Next: Find the first n Fibonacci numbers.
Python Code Editor :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.