Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedin 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions