Skip to content

Instantly share code, notes, and snippets.

@palewire
Last active March 14, 2022 11:51
Show Gist options
  • Save palewire/6fda3c6b85f0ef0011434f1e4c54dbdd to your computer and use it in GitHub Desktop.
Save palewire/6fda3c6b85f0ef0011434f1e4c54dbdd to your computer and use it in GitHub Desktop.
numoji.py
def numoji(number):
"""Convert a number into a series of emojis.
Args:
number (int): The number to convert into emoji
Returns: Am emoji string
"""
# Convert the provided number to a string
s = str(number)
# Split it into a list of tokens, one per number
parts = list(s)
# Create crosswalk between numerals and emojis
lookup = {
'0': "0️⃣",
'1': "1️⃣",
'2': "2️⃣",
'3': "3️⃣",
'4': "4️⃣",
'5': "5️⃣",
'6': "6️⃣",
'7': "7️⃣",
'8': "8️⃣",
'9': "9️⃣",
}
# Look up each of the tokens in the crosswalk
emojis = list(map(lookup.get, parts))
# Join it all together and return the result
return "".join(emojis)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment