← Back to challenges

Array of Word Lengths

PythonMediumarrayslanguage_fundamentals

Instructions

Create a function that takes a list of words and transforms it into a list of each word's length.

Examples

word_lengths(["hello", "world"]) ➞ [5, 5]

word_lengths(["Halloween", "Thanksgiving", "Christmas"]) ➞ [9, 12, 9]

word_lengths(["She", "sells", "seashells", "down", "by", "the", "seashore"]) ➞ [3, 5, 9, 4, 2, 3, 8]

Notes

  • No test case will contain punctuation.
  • Lists can be of various lengths.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Add a Consecutive List of Numbers