Last active
March 14, 2022 11:51
-
-
Save palewire/6fda3c6b85f0ef0011434f1e4c54dbdd to your computer and use it in GitHub Desktop.
numoji.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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