Write a program that receives a number and displays the letter equivalent of that number. Write the program so that for Nomadillion (usable. For negative numbers, write the word "negative" first) such as negative one (. �� to �� �� numbers from ��− Use the small-scale (American) mode to name large numbers. And ... use to name numbers
Asked
Active
Viewed 77 times
-1
-
1There is no "*letter equivalent of [a] number*", only conventions. You need to be more explicit – mozway Jan 06 '22 at 09:11
-
Does this answer your question? [How do I tell Python to convert integers into words](https://stackoverflow.com/questions/8982163/how-do-i-tell-python-to-convert-integers-into-words) – Chris Jan 06 '22 at 09:16
-
@amirhosseinzadeh What do you mean by Nomadillion? I could not understand the last 2 sentences, maybe you can clarify those. – Chris Jan 06 '22 at 09:18
1 Answers
1
There are at least 2 libraries for this usecase: inflect and num2word. Try these examples, from there you can extend the program to include negative formatting.
>>>import inflect
>>>p = inflect.engine()
>>>p.number_to_words(99)
ninety-nine
>>> import num2word
>>> num2word.to_card(15)
'fifteen'
>>> num2word.to_card(55)
'fifty-five'
>>> num2word.to_card(1555)
'one thousand, five hundred and fifty-five'

Chris
- 347
- 2
- 14