Advertisement
emily_n2

Emoji Detector

Apr 6th, 2020
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. import re
  2. line = input()
  3. pattern1 = r'(\d)'
  4. cool = 1
  5. pattern2 =r'(::|\*\*)([A-Z][a-z]{2,})\1'
  6.  
  7. digits = re.findall(pattern1,line)
  8. for d in digits:
  9.     cool *= int(d)
  10. print(f'Cool threshold: {cool}')
  11.  
  12. emojis = re.findall(pattern2, line)
  13.  
  14. ll = []
  15. for em in emojis:
  16.     sum = 0
  17.     for char in em[1]:
  18.         sum += ord(char)
  19.     if sum >= cool:
  20.         ll.append(em)
  21.  
  22. print(f'{len(emojis)} emojis found in the text. The cool ones are:')
  23. for em in ll:
  24.     print(f'{em[0]}{em[1]}{em[0]}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement