Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MinMaxWordFinder:
- def __init__(self):
- self.sp = []
- def add_sentence(self, word):
- self.sp += word.split()
- def shortest_words(self):
- min_len = min(self.sp, key=len)
- return list(filter(lambda x: len(x) == len(min_len), self.sp))
- def longest_words(self):
- max_len = max(self.sp, key=len)
- return list(filter(lambda x: len(x) == len(max_len), self.sp))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement