Advertisement
Guest User

Untitled

a guest
Apr 10th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. import re
  2.  
  3. text = input()
  4.  
  5. ats = re.findall('@\w+@@\w+@', text)
  6. hashs = re.findall('#\w+##\w+#', text)
  7. cond_list = ats + hashs
  8. if len(cond_list) == 0:
  9.     print('No word pairs found!')
  10. else:
  11.     for i in cond_list:
  12.         if '_' in i or len(i.replace('@', '').replace('#', '')) < 6:
  13.             cond_list.remove(i)
  14.     print(f'{len(cond_list)} word pairs found!')
  15.     mirror_words = []
  16.     for i in cond_list:
  17.         words = i.replace('@', '').replace('#', '')
  18.         if words[:len(words)] == words[-1:len(words)]:
  19.             mirror_words.append(f'{words[:len(words)]} <=> {words[-1:len(words)]}')
  20.     if len(mirror_words) == 0:
  21.         print("No mirror words!")
  22.     else:
  23.         print(f""""The mirror words are:
  24. {', '.join(mirror_words)}
  25. """)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement