May-07-2022, 08:49 AM
(This post was last modified: May-07-2022, 10:14 AM by snippsat.
Edit Reason: Fix code tag
)
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.
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)
