Question: in python! In the space below, write a recursive Python function (digitSum(s) ) that takes in a string s as its parameter and returns an
in python!
In the space below, write a recursive Python function (digitSum(s) ) that takes in a string s as its parameter and returns an integer representing the sum of all digits (0,1,2,3,4,5,6,7,8,9) in s. If s is an empty string or a string without any digits, then this function will return o as shown in the assert statements below. Your solution should be a complete recursive function definition with appropriate syntax and indentation. Note: 1. your solution must be recursive (and follow the three laws of recursion). 2. your solution cannot use any helper functions. 3. your function definition must be syntactically correct in order to receive full credit. If your recursive function is implemented correctly, then the following assert statements should pass: == == 6 assert digitSum("") 0 assert digitSum("123") assert digitSum("CS9") == assert digitSum( "Python") assert digitSum("h3LLO") 9 == 0 == 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
