0

I need to generate a sequence of numbres, for example from 1 to 100 (this number could be much greater) in an array but as text like

[
    'one',
    'two',
    'three',
    ...
    'one hundred',
]

is there a library that do this? or i have to do it manually? and if there is a way to do it in spanish will be a plus.

Carlos Salazar
  • 1,818
  • 5
  • 25
  • 48

3 Answers3

0

use inflect:

>>>import inflect
>>>p = inflect.engine()
>>>p.number_to_words(1234)
u'one thousand, two hundred and thirty-four'
malmiteria
  • 119
  • 2
  • 8
-1

This might help you but in order to do it in spanish you need to understand the code and change the code a little https://www.geeksforgeeks.org/convert-number-to-words/

EDIT: I think this will help you more there are multiple languages supported in this module https://pypi.org/project/num2words/

jaswanth
  • 515
  • 2
  • 7
-3

You have to do it manually just use replace.

Pat Larkin
  • 29
  • 1
  • 3