Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- filter_input = input()
- letter, needed_count = filter_input[0], int(filter_input[1])
- filtered_words = []
- while True:
- sentence = input()
- if sentence == "end":
- break
- if re.match(r'^[A-Z].*[.!?]$', sentence):
- words = re.findall(r'\w+', sentence)
- for word in words:
- count = sum(1 for char in word if char == letter)
- if count >= needed_count:
- filtered_words.append(word)
- print(", ".join(filtered_words))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement