Advertisement
Osiris1002

Emoji Detector

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