Skip to content

Instantly share code, notes, and snippets.

@igorvanloo
Created July 21, 2021 06:01
Show Gist options
  • Save igorvanloo/332db399ddbc1ca5c62dc4b1239b7543 to your computer and use it in GitHub Desktop.
Save igorvanloo/332db399ddbc1ca5c62dc4b1239b7543 to your computer and use it in GitHub Desktop.
Problem 17
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