How to convert numbers to words in Python

2 Answers

0 votes
from num2words import num2words 
  
n = 24

print(num2words(n)) 
  
print(num2words(n, to = 'ordinal'))

print(num2words(n, to = 'ordinal_num')) 

print(num2words(n, to = 'year')) 

 
          
       
'''
run:

twenty-four
twenty-fourth
24th
twenty-four
       
'''

 



answered Apr 30, 2020 by avibootz
0 votes
import inflect
 
n = 12853279456
 
ie = inflect.engine()
 
words = ie.number_to_words(n)
 
 
print(words)
           
        
'''
run:
 
one hundred and twenty-eight million, five hundred and thirty-two thousand, seven hundred and ninety-four
        
'''

 



answered Apr 30, 2020 by avibootz
edited Sep 5 by avibootz
...