Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def numberToText(n):
- digits = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
- teens = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"]
- adults = ["twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"]
- text = ""
- if (n < 0 or n > 100): text = "invalid number"
- elif (n <= 9): text = digits[n % 10]
- elif (n <= 19): text = teens[n % 10]
- elif (n <= 99 and n % 10 == 0): text = adults[int(n / 10) - 2]
- elif (n <= 99 and n % 10 != 0): text = adults[int(n / 10) - 2] + ' ' + digits[n % 10]
- else: text = "one hundred"
- return text
- n = int(input())
- print(numberToText(n))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement