Spanish Numbers API

spanum.numbers_to_words.number_to_words(n)

Converts a number to its Spanish word representation.

Example:

>>> from spanum.numbers_to_words import number_to_words
>>> number_to_words(42)
'cuarenta y dos'
Parameters:

n (int) – Any number you want to convert.

Raises:

ValueError – If the number is too big.

Returns:

The Spanish word for the provided number.

Return type:

str

spanum.words_to_numbers.words_to_number(text)

Converts a Spanish numeral to an integer.

Example:

>>> from spanum.words_to_numbers import words_to_number
>>> words_to_number('cuarenta y dos')
42
Parameters:

text (str) – Any Spanish numeral you want to convert.

Raises:

ValueError – Occurs when an unknown word is found in the text.

Returns:

The integer value corresponding to the provided Spanish numeral.

Return type:

int