Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def convert(num):
- units = ("zero", "one ", "two ", "three ", "four ","five ", "six ", "seven ","eight ", "nine ", "ten ", "eleven ", "twelve ", "thirteen ", "fourteen ", "fifteen ","sixteen ", "seventeen ", "eighteen ", "nineteen ")
- tens =("", "", "twenty ", "thirty ", "forty ", "fifty ","sixty ","seventy ","eighty ","ninety ")
- if num < 0:
- return "minus "+convert(-num)
- if num<20:
- return units[num]
- if num<100:
- return tens[num // 10] +units[int(num % 10)]
- if num<1000:
- return units[num // 100] +"hundred " +convert(int(num % 100))
- print(convert(999))
- '''numbers number as words
- 0 Zero
- 9 Nine
- 10 Ten
- 12 Twelve
- 19 Nineteen
- 25 Twenty five
- 98 Ninety eight
- 98 Ninety eight
- 273 Two hundred and seventy three
- 400 Four hundred
- 501 Five hundred and one
- 617 Six hundred and seventeen
- 711 Seven hundred and eleven
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement