Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Convert written out numbers to integers

Project Description

Convert spelled numbers such as ‘one thousand, two hundred and thirty-three’ or ‘one thousand two hundred thirty three’ to their equivalent forms in digits (1233).

Handles British-style “and” as well as US versions without “and”, and accepts commas and hyphens in appropriate positions (although they are never compulsory)

>>> spelled_num_to_digits("one")
>>> spelled_num_to_digits("twelve")
>>> spelled_num_to_digits("seventy-two")
>>> spelled_num_to_digits("Three hundred")
>>> spelled_num_to_digits("TWELVE HUNDRED")
>>> spelled_num_to_digits("twelve thousand three hundred four")
>>> spelled_num_to_digits("twelve thousand, five hundred and six")
>>> spelled_num_to_digits("six   Million")
>>> spelled_num_to_digits("six million four hundred thousand five")
>>> spelled_num_to_digits(
...   'one hundred twenty three billion, four hundred fifty six million, '
...   'seven hundred eighty nine thousand twelve')
>>> spelled_num_to_digits("four decillion")
>>> replace_spelled_numbers('There are TEN sponges')
'There are 10 sponges'
>>> replace_spelled_numbers('I got ninety nine problems')
'I got 99 problems'
>>> replace_spelled_numbers('He got two million, one hundred and '
...   'eighty-two thousand, three hundred and twenty five problems')
'He got 2182325 problems'
>>> replace_spelled_numbers('I have five coconuts and two hundred '
...   'thirty three carrots')
'I have 5 coconuts and 233 carrots'

Adapted and extended from

Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
Digify-0.2.tar.gz (2.2 kB) Copy SHA256 Checksum SHA256 Source Jan 7, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting