The Python Coding Stack

The Python Coding Stack

The Club

Field Notes: First, Second, and Five Hundred and Twenty-Third • [Club]

Have you ever needed to convert numbers like 22 into the string “twenty-two” or 523 into “five hundred and twenty-third”?

Stephen Gruppetta's avatar
Stephen Gruppetta
Mar 09, 2026
∙ Paid

Most of my posts on The Python Coding Stack, whether in the main publication or here in The Club, typically focus on some aspect of core Python and explore it through a step-by-step approach, a mini-project, or sometimes through an essay-type article.

But today, I’ll write a short post about some tools I came across that may be interesting. I’ll keep the post short since, if you’re interested, you can easily explore the packages independently – you won’t need my explanatory efforts.


Remember some of the earliest code you ever wrote? It may have looked like this:

first = input(”Enter the first number: “)
second = input(”Enter the second number: “)
print(
    f”The sum of the two numbers is {float(first) + float(second)}”
)

Those days are long gone. But what if you wanted this code to work for any number of inputs, not just two?

I’m not talking about the code to work out the sum itself. You’d probably use a list to collect all the numbers and the sum() built-in function, or just use a running total. Whatever.

The annoying part is making user-friendly strings when asking for the input – it’s fine to write "first" and "second" when there are only two prompts – and then when showing the result, which currently says "two numbers". But what if you have more?

I came across this need several times, but my solution has always been to change the string so that it’s general enough to work in all cases. I’m lazy, I know.

In any case, recently I decided to look for solutions. And of course, they exist! Everything seems to exist in the Python ecosystem. Several solutions…

num2words

The first solution is probably the simplest: the num2words package doesn’t do much beyond converting numbers to words, as its name suggests. You’ll need to install num2words using pip, uv, or whatever you use to install packages.

>>> import num2words
>>> num2words.num2words(34)
‘thirty-four’

The main function in the num2words module is also called num2words(), as often happens with such modules!

How far can it go?

>>> num2words.num2words(5468.23)
‘five thousand, four hundred and sixty-eight point two three’

Working in Spanish?

>>> num2words.num2words(5468.23, lang=”es”)
‘cinco mil cuatrocientos sesenta y ocho punto dos tres’

Or Japanese?

>>> num2words.num2words(5468.23, lang=”ja”)
‘五千四百六十八点二三’

This post is for paid subscribers

Already a paid subscriber? Sign in
© 2026 Stephen Gruppetta · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture