0

I have been working on this question for some time now, and really got stuck with few input values, and I am unable to understand the actual error/solve the error.

Question: In a file called emojize.py, implement a program that prompts the user for a str in English and then outputs the “emojized” version of that str, converting any codes (or aliases) therein to their corresponding emoji.

My Code:

import emoji

a = str(input("Input: ")).strip()
b = emoji.emojize(a)

print("Output:",b)

Expected Outputs `> python emojize.py

Input: :thumbs_up:
Output: 👍
python emojize.py
Input: :thumbsup:
Output: 👍
python emojize.py
Input: hello, :earth_africa:
Output: hello, 🌍 python emojize.py
Input: hello, :earth_americas:
Output: hello, 🌎
python emojize.py
Input: hello, :earth_asia:
Output: hello, 🌏 `

Expected outputs with errors

  1. :) emojize.py exists
  2. :) input of ":1st_place_medal:" yields output of 🥇
  3. :( input of ":thumbsup:" yields output of 👍 expected "👍", not "Input: Output:..."
  4. :( input of "hello, :earth_asia:" yields output of hello, 🌏 expected "hello, 🌏", not "Input: Output:..."
  5. :) input of ":candy: or :ice_cream:?" yields output of 🍬 or 🍨?

The error in point 3 and point 4, is what I am getting, but I am unable to understand what does that mean. So I don't really know how to fix that. Can somebody please help?

According to me I believe there should either be no error, or I should get error for all the inputs. But that's not what's happening here, and I am really unable to understand the error messages.

1 Answer 1

1

Correct answer:

import emoji

a = str(input("Input: ")).strip()
b = emoji.emojize(a, language='alias')

print(b)
1
  • This worked for me, thanks.
    – Rufus L
    Commented Jun 19 at 21:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .