Python Forum
General Programming Question with Dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
General Programming Question with Dictionary
#6
So you'll need to create a parser for that, and I'm not sure it will be easy unless you already know your input will be restricted to certain types. Here's a couple of items that might be challenging to distinguish:

"The car was priced at $52,400."
"I've got red, green, and blue, with 100,200, and 75 respectively"

You might take a look at https://pypi.org/project/inflect/. It can turn numbers (or strings of digits) into english terms (assuming you've already parsed the correct number).

>>> import inflect
>>> p = inflect.engine()
>>> p.number_to_words(52400)
'fifty-two thousand, four hundred'
>>> p.number_to_words("52400")
'fifty-two thousand, four hundred'
Reply


Messages In This Thread
RE: General Programming Question with Dictionary - by bowlofred - Jan-07-2022, 07:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python can - general question caslor 0 1,139 Jul-14-2022, 05:21 PM
Last Post: caslor
  a general question barryjo 5 1,557 Feb-01-2022, 10:12 PM
Last Post: Gribouillis
Big Grin General programming question (input string)[ jamie_01 2 1,640 Jan-08-2022, 12:59 AM
Last Post: BashBedlam
  Question about formula implementation in general format Alienspecimen 0 1,681 Mar-01-2021, 08:39 PM
Last Post: Alienspecimen
  General list size question to solve problem Milfredo 3 2,392 Sep-27-2020, 08:42 AM
Last Post: Milfredo
  New to programming, loop question tomyan 1 1,674 Sep-25-2020, 04:32 PM
Last Post: Larz60+
  General Listbox question. Milfredo 4 2,207 Sep-06-2020, 07:36 PM
Last Post: Milfredo
  Dictionary question DrZ 2 1,685 Jul-29-2020, 08:53 PM
Last Post: DrZ
  General question about serialization/deserialization in python local 1 1,871 Jan-28-2020, 04:35 AM
Last Post: Larz60+
  General Programming Question Qui_Ten 1 2,214 Jan-14-2019, 11:15 AM
Last Post: steve_shambles

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020