Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Emoji Dictionary Help
#1
Hello,

So I am trying to replace words from the sentence input by the relevant emoji from this dictionary. In the end i would like to reprint the sentence containing the replaced emojis.
Below is the code I've attempted to write so far, but I cannot get the complete sentence to print properly.
emoji_dict = {
    "happy": "😃",
    "heart": "😍",
    "rotfl": "🤣",
    "smile": "😊",
    "crying": "😭",
    "kiss": "😘",
    "clap": "👏",
    "grin": "😁",
    "fire": "🔥",
    "broken": "💔",
    "think": "🤔",
    "excited": "🤩",
    "boring": "🙄",
    "winking": "😉",
    "ok": "👌",
    "hug": "🤗",
    "cool": "😎",
    "angry": "😠",
    "python": "🐍",
}

sentence = input("Please enter a sentence: ")
words = sentence.split()

print(words)

emoji_words = ("")

for word in words:
    if word in emoji_dict:
        word = emoji_dict[word]
    emoji_words += word

print(emoji_words)
snippsat write May-07-2022, 10:14 AM:
Added code tag in your post,look at BBCode on how to use.
Reply


Messages In This Thread
Emoji Dictionary Help - by rewainy - May-07-2022, 08:49 AM
RE: Emoji Dictionary Help - by menator01 - May-07-2022, 09:40 AM
RE: Emoji Dictionary Help - by snippsat - May-07-2022, 10:17 AM
RE: Emoji Dictionary Help - by rewainy - May-07-2022, 01:13 PM
RE: Emoji Dictionary Help - by snippsat - May-07-2022, 01:46 PM
RE: Emoji Dictionary Help - by rewainy - May-08-2022, 04:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  fontforge Emoji encoding and colored glyphs pauf28 0 2,197 Dec-22-2020, 10:05 AM
Last Post: pauf28
  Because the emoji appears black and white at the exit ? nerd 3 5,659 Jan-28-2019, 11:34 PM
Last Post: nerd
  I can not install the emoji module nerd 1 4,364 Jan-27-2019, 05:53 AM
Last Post: nerd

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020