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'])
[]
'''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.
The input is a series of lines, each containing one or more words.
The result returned by function repeated_short(lw)
must be a sorted list with all repeated short words in the
line.
The output printed by the main program must be –for each line in the input– the number of short repeated words followed by the alphabetically sorted list of those words, in the format shown in the examples below.
Author: ProAl professors
Generation: 2026-01-25T17:30:13.127Z
© Jutge.org, 2006–2026.
https://jutge.org