Question: please use python to solve the question PROBLEMS 1. Write a function, addNums(d,s) which takes a dictionary and a string which uses ,' as a
PROBLEMS 1. Write a function, addNums(d,s) which takes a dictionary and a string which uses ,' as a delimiter. The values in string are keys into the dictionary. Take each substring in string and get the associated value in the dictionary. Accumulate a total value using the values from the dictionary. Return the total and Key Errors list as shown. The Key Errors list is a list of substrings in the string which are not keys in the dictionary. The Key Errors list must contain unique key values only. To get full credit you must use try/except KeyError and .format. This function returns the total followed by the list of keys which were in error. See below for sample outputs. addNumsCt'zero':0, 'one':1, two':2, three':3), 'one,one, two, four, three,zero) Total:7, Key Errors: C'four'1 o "Total: , Key Errors: ['four 'five', 'six']" "Total: , Key Errors: C'four, five, six'" 5. oddNums(i zero':e, one :1, two':2, three' :3), three, three, three') Total: 9, Key Errors: C >>> addNurmsU' zero' : 0 , 'one' : 1 , ' two ' : 2 , ' three-3),') Total: 8, Key Errors: C
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
