Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 == 3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started