I\'m trying to return words that have a specific length size.
The words is a list and size is a positive integer here. The result should be
words
size
def by_size(words,size): result = [] for word in words: if len(word)==size: result.append(word) return result
Now call the function like below
desired_result = by_size(['a','bb','ccc','dd'],2)
where desired_result will be ['bb', 'dd']
desired_result
['bb', 'dd']