Dictionaries · 13 / 15 Exercise Medium

Group by length

Objective

Create a Python program that groups the words of a sentence by their length.

Instructions

  • Read a line with words separated by spaces.
  • Store in a dictionary, for each length, the list of words of that length, in the order in which they appear.
  • Show one line per length, from smallest to largest, with the format length: word1 word2 ....
Input
el sol sale por el mar
Output
2: el el
3: sol por mar
4: sale

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

Start exercise