bl00dt3ars

02. Emoji Detector

Jun 27th, 2021 (edited)
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.57 KB | None | 0 0
  1. import re
  2.  
  3. text = input()
  4. pattern = r"([:]{2}|[*]{2})([A-Z]{1}[a-z]{2,})(\1)"
  5. emojis_found = re.findall(pattern, text)
  6. threshold = 1
  7.  
  8. for digits in text:
  9.     if digits.isdigit():
  10.         threshold *= int(digits)
  11.  
  12. print(f"Cool threshold: {threshold}")
  13. if len(emojis_found) > 0:
  14.     print(f"{len(emojis_found)} emojis found in the text. The cool ones are:")
  15.     for emoji in emojis_found:
  16.         points_of_emoji = 0
  17.         for char in emoji[1]:
  18.             points_of_emoji += ord(char)
  19.         if points_of_emoji >= threshold:
  20.             print("".join(emoji))
Add Comment
Please, Sign In to add comment