Comprehensions and functional programming · 8 / 15 Exercise Easy

Word lengths

Objective

Create a Python program that calculates the length of each word of a sentence with a list comprehension.

Instructions

  • Read a line with words separated by spaces.
  • Build with a comprehension the list with the length of each word.
  • Show the lengths on a single line, separated by a space.
Input
el sol sale por el mar
Output
2 3 4 3 2 3

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise