Repeated Short Words

  1. Write a function: repeated_short(lw) that given a list of words lw, returns a list with those words that are shorter than 5 letters and appear more than once in the list. The returned list must be alphabetically sorted.

    def repeated_short(lw):
        '''
        >>> repeated_short(['easy','come','easy','go','will','you','let','me','go'])
        ['easy', 'go']
        >>> repeated_short(['I','can','see','it','can','you','see','it'])
        ['can', 'it', 'see']
        >>> repeated_short(['unbelievable','unbelievable'])
        []
        '''
  2. Write a main program that reads lines from the input, and prints the number of repeated word shorter than 5 letters in each line, and the list of those words. The main program must use the repeated_short(lw) function defined above.

Input

The input is a series of lines, each containing one or more words.

Output

Problem information

Author: ProAl professors

Generation: 2026-01-25T17:30:13.127Z

© Jutge.org, 2006–2026.
https://jutge.org