You can download this code by clicking the button below.
This code is now available for download.
This function takes a list of words as input and returns a new list with the words sorted by their length.
Technology Stack : list, sorted, key
Code Type : Function
Code Difficulty : Intermediate
def sort_words_by_length(words):
"""
Sorts a list of words based on their length.
"""
return sorted(words, key=len)