Created
January 7, 2015 07:35
-
-
Save bruckhaus/1f03a7760875fd170bea to your computer and use it in GitHub Desktop.
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 in_words(i): | |
d = NumberLetterCounts.NUMBER_WORDS | |
words = '' | |
if i >= 1000: | |
thousands = i / 1000 | |
i %= 1000 | |
words = d[thousands] + " thousand" | |
if i > 0: | |
words += " " | |
if i >= 100: | |
hundreds = i / 100 | |
i %= 100 | |
words += d[hundreds] + " hundred" | |
if i > 0: | |
words += " and " | |
if i >= 20: | |
tens = i / 10 | |
i %= 10 | |
words += d[tens * 10] | |
if i > 0: | |
words += "-" | |
if i > 0: | |
words += d[i] | |
return words |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment