Question: In Python: Write both a non-recursive and a recursive function that determines how many times a given letter occurs in a given string. Your program

In Python:

Write both a non-recursive and a recursive function that determines how many times a given letter occurs in a given string.

Your program should contain two functions, one that is non-recursive and one that is recursive. Your methods should take a string and a character as input, then return an integer representing number of occurrences.

Your program should also include the main program. Your main program should prompt the user for a string and then for a character to search for in that string. Output how many occurrences of that character were found in the string.

Example output might look like:

Enter a word: hello Enter a character to look for in that word: l There are 2 of l in hello Now searching recursively... There are also 2 of l in hello

Add comments to your program starting with your name at the top, then throughout your program to describe what you are doing. Be sure and make your calculations clear, giving your variables meaningful names. Also be sure to indent consistently throughout your program to make it more readable. Be sure you run this and test it a few times before submitting.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!