Dec-21-2019, 05:16 PM
(This post was last modified: Dec-21-2019, 05:16 PM by Gribouillis.)
If you don't mind using someone else's code, there is a module in pypi named 'text2digits' under the MIT licence that does the number conversion
>>> from text2digits import text2digits >>> td2 = text2digits.Text2Digits() >>> td2.convert("I'm twenty five years old") "I'm 25 years old" >>> td2.convert("seventy two") '72'Considering that you are a beginner in python, it would probably be a good idea to use this code instead of rewriting your own. You will probably meet many other issues before the project is complete.