DiYane

Emoji Detector

Aug 10th, 2023
635
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import re
  2.  
  3. text = input()
  4. pattern = r'([:]{2}|[*]{2})([A-Z]{1}[a-z]{2,})(\1)'
  5. matches = re.findall(pattern, text)
  6.  
  7. threshold = 1
  8. for char in text:
  9.     if char.isdigit():
  10.         threshold *= int(char)
  11.  
  12. cool_emojis = []
  13. for emoji in matches:
  14.     coolnes = 0
  15.     for char in emoji[1]:
  16.         coolnes += ord(char)
  17.  
  18.     if coolnes > threshold:
  19.         cool_emojis.append(emoji)
  20.  
  21. print(f'Cool threshold: {threshold}')
  22. if len(matches) > 0:
  23.     print(f'{len(matches)} emojis found in the text. The cool ones are:')
  24.     for emoji in cool_emojis:
  25.         print(''.join(emoji))
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment