Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- text = input()
- ats = re.findall('@\w+@@\w+@', text)
- hashs = re.findall('#\w+##\w+#', text)
- cond_list = ats + hashs
- if len(cond_list) == 0:
- print('No word pairs found!')
- else:
- for i in cond_list:
- if '_' in i or len(i.replace('@', '').replace('#', '')) < 6:
- cond_list.remove(i)
- print(f'{len(cond_list)} word pairs found!')
- mirror_words = []
- for i in cond_list:
- words = i.replace('@', '').replace('#', '')
- if words[:len(words)] == words[-1:len(words)]:
- mirror_words.append(f'{words[:len(words)]} <=> {words[-1:len(words)]}')
- if len(mirror_words) == 0:
- print("No mirror words!")
- else:
- print(f""""The mirror words are:
- {', '.join(mirror_words)}
- """)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement