Skip to content

Instantly share code, notes, and snippets.

@xpe xpe/numeronym.py
Last active Oct 7, 2019

Embed
What would you like to do?
Use this when your phrases need numeronyms!
def abbreviate(phrase):
def shorten(w, t=7):
if len(w) <= t:
return w
else:
return "{}{}{}".format(w[0], len(w)-2, w[-1])
return " ".join([shorten(w) for w in phrase.split(" ")])
abbreviate("The Heilmeier Catechism demands a thoughtful approach to risk taking")
# 'The H7r C7m demands a t8l a6h to risk taking'
@xpe

This comment has been minimized.

Copy link
Owner Author

xpe commented Oct 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.