Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- some_string = input()
- mirror_words = []
- pattern = r"(?i)(#|@)([a-z]{3,})\1{2}([a-z]{3,})\1"
- matches = re.findall(pattern, some_string)
- if len(matches) == 0:
- print("No word pairs found!")
- else:
- print(f"{len(matches)} word pairs found!")
- for match in matches:
- first_word = match[1]
- second_word = match[2]
- if first_word == second_word[::-1]:
- mirror_words.append(f"{first_word} <=> {second_word}")
- if len(mirror_words) == 0:
- print("No mirror words!")
- else:
- print("The mirror words are:")
- print(*mirror_words, sep=", ")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement