Advertisement
WupEly

Untitled

Apr 24th, 2023
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. class MinMaxWordFinder:
  2. def __init__(self):
  3. self.sp = []
  4.  
  5. def add_sentence(self, word):
  6. self.sp += word.split()
  7.  
  8. def shortest_words(self):
  9. min_len = min(self.sp, key=len)
  10. return list(filter(lambda x: len(x) == len(min_len), self.sp))
  11.  
  12. def longest_words(self):
  13. max_len = max(self.sp, key=len)
  14. return list(filter(lambda x: len(x) == len(max_len), self.sp))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement