Python Forum
General Programming Question with Dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
General Programming Question with Dictionary
#1
I have a dictionary that contains books names, numbers of pages, who wrote the book, etc. What I attempting to do is search the whole dictionary for all the numbers for example 1,56,54 and even numbers as such 1894-3999 RT and replace/update them with the spelling of the numbers.
I came up with the following after trying different combinations :
value  = re.findall(r'[0-9]+', str(cybc)) #Find all the numbers in dictionary
for t in value: #Loop through Values
    cybc.update(num2words(int(t))) #Update Dictionary with new values
    print('With Words',num2words(int(t))) # Print the spelled out words
However when ran I get the following error message:
ValueError: dictionary update sequence element #0 has length 1; 2 is required
What are the final steps to finish this? As I know there is something small to finish it but I cannot seem to figure it out. Thanks.
Reply


Messages In This Thread
General Programming Question with Dictionary - by giddyhead - Jan-07-2022, 05:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  python can - general question caslor 0 1,123 Jul-14-2022, 05:21 PM
Last Post: caslor
  a general question barryjo 5 1,521 Feb-01-2022, 10:12 PM
Last Post: Gribouillis
Big Grin General programming question (input string)[ jamie_01 2 1,607 Jan-08-2022, 12:59 AM
Last Post: BashBedlam
  Question about formula implementation in general format Alienspecimen 0 1,669 Mar-01-2021, 08:39 PM
Last Post: Alienspecimen
  General list size question to solve problem Milfredo 3 2,368 Sep-27-2020, 08:42 AM
Last Post: Milfredo
  New to programming, loop question tomyan 1 1,647 Sep-25-2020, 04:32 PM
Last Post: Larz60+
  General Listbox question. Milfredo 4 2,161 Sep-06-2020, 07:36 PM
Last Post: Milfredo
  Dictionary question DrZ 2 1,669 Jul-29-2020, 08:53 PM
Last Post: DrZ
  General question about serialization/deserialization in python local 1 1,851 Jan-28-2020, 04:35 AM
Last Post: Larz60+
  General Programming Question Qui_Ten 1 2,191 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