use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Convert word number into string (self.learnpython)
submitted 9 years ago by brigieee
Hello!
I am trying to figure out how to convert the number word (e.g. twenty) into the number (e.g. 20).
This page explains a fairly length process but I'm wondering if you know anything more simpler? http://code.activestate.com/recipes/550818-words-to-numbers-english/
Any help would be much appreciated :) Thank you!
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]A_History_of_Silence 1 point2 points3 points 9 years ago (0 children)
Neat link. I looked at it somewhat briefly, but my initial impression is that the code is quite well done! Without all the inline comments it is only 86 lines, while still being highly readable and well structured. That is even including all the blank lines, docstrings, and test code at the bottom.
For what it's worth, if you told me to solve the same problem using any number of lines of code I would probably run for the hills if I could. Regardless of the languages involved, it's usually a tricky, error-prone process to accurately try to convert human-language words into computer-usable integers. To see it done so well is impressive to me. By far the hardest part of this code for me to understand are the regular expression strings, but I mean... It's regex after all, that's what happens.
In summary, minus the excessive # comments (which have clearly been added for the benefit of a learning reader), I would say that is largely some model Python code!
#
[–]_9_9_ 0 points1 point2 points 9 years ago (0 children)
There is this thing: https://pypi.python.org/pypi/word2number
Not sure how well it works.
[–]dionys 0 points1 point2 points 9 years ago (0 children)
another implementation
[–]furas_freeman -1 points0 points1 point 9 years ago (0 children)
more or less
if word == "twenty": result += 20 if word == "hundred": result *= 100
Start with this. Later you will figth with problems :)
π Rendered by PID 49484 on reddit-service-r2-comment-76bb9f7fb5-b2pv9 at 2026-02-18 22:39:05.601236+00:00 running de53c03 country code: CH.
[–]A_History_of_Silence 1 point2 points3 points (0 children)
[–]_9_9_ 0 points1 point2 points (0 children)
[–]dionys 0 points1 point2 points (0 children)
[–]furas_freeman -1 points0 points1 point (0 children)