Question: 2. Write a function count_spaces(s) that takes an arbitrary string input s and uses recursion to determine and return the number of spaces in s.

2. Write a function count_spaces(s) that takes an arbitrary string input s and uses recursion to determine and return the number of spaces in s. For example: >>> count_spaces('fee fi fo fum') result: 3 >>> count_spaces('hello world') result: 1 >>> count_spaces('howdy') result: 0 This function is similar to the num_vowels function from lecture
Step by Step Solution
There are 3 Steps involved in it
To solve the problem of counting the number of spaces in a string using recursion we will write a re... View full answer
Get step-by-step solutions from verified subject matter experts
