(file_path)
| 7 | |
| 8 | |
| 9 | def display_words(file_path): |
| 10 | try: |
| 11 | with open(file_path) as F: |
| 12 | words = F.read().split() |
| 13 | words_less_than_40 = list(filter(lambda word: len(word) < 4, words)) |
| 14 | |
| 15 | for word in words_less_than_40: |
| 16 | print(word) |
| 17 | |
| 18 | return ( |
| 19 | "The total number of the word's count which has less than 4 characters", |
| 20 | (len(words_less_than_40)), |
| 21 | ) |
| 22 | |
| 23 | except FileNotFoundError: |
| 24 | print("File not found") |
| 25 | |
| 26 | |
| 27 | print("Just need to pass the path of your file..") |