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

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

1 Expert Approved Answer
Step: 1 Unlock

To solve the problem of counting the number of spaces in a string using recursion we will write a re... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!