Created
July 21, 2021 06:01
-
-
Save igorvanloo/332db399ddbc1ca5c62dc4b1239b7543 to your computer and use it in GitHub Desktop.
Problem 17
This file contains hidden or 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 Number_to_english(x): | |
if x < 20: | |
return ONES[x] | |
elif 20 <= x < 100: | |
return TENS[x // 10] + ONES[x % 10] | |
elif 100 <= x < 1000: | |
if x == 100: | |
return "onehundred" | |
else: | |
if x % 100 == 0: | |
return ONES[ x // 100] + "hundred" | |
else: | |
return ONES[ x // 100] + "hundred" + "and" + Number_to_english(x % 100) | |
elif x == 1000: | |
return "onethousand" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment