Member-only story

Generate Emoji using Python

Python Coding
2 min readSep 17, 2024

--

pip install emoji

import emoji

def text_to_emoji(text):
return emoji.emojize(text)
input_text = input("Enter text with emoji aliases : ")

converted_text = text_to_emoji(input_text)

print("Converted Text with Emojis:", converted_text)

1. Importing the emoji Library:

import emoji
  • The emoji library is imported here. This library helps convert text containing emoji aliases (such as :smile:) into actual emojis (like 😊).

2. Defining the text_to_emoji Function:

def text_to_emoji(text):
return emoji.emojize(text)
  • The function text_to_emoji takes a string text as input.
  • It uses the emoji.emojize() method from the emoji library to convert emoji aliases (like :smile:) within the input text into actual emoji characters (like 😊).
  • The function returns the converted text.

3. Getting User Input:

input_text = input("Enter text with emoji aliases : ")
  • This line prompts the user to input text, which can include emoji aliases (for example, Hello :smile:).
  • The user input is stored in the input_text variable.

--

--

Python Coding
Python Coding

Written by Python Coding

Learn python tips and tricks with code I Share your knowledge with us to help society. Python Quiz: https://www.clcoding.com/p/quiz-questions.html

No responses yet