Jan-07-2022, 05:59 AM
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 :
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 wordsHowever when ran I get the following error message:
ValueError: dictionary update sequence element #0 has length 1; 2 is requiredWhat 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.