This is a Python Program to determine how many times a given letter occurs in a string recursively.
The program takes a string and determines how many times a given letter occurs in a string recursively.
1. Take a string and a character from the user and store it in different variables.
2. Pass the string and the characters as arguments to a recursive function.
3. Pass the base condition that the string isn’t empty.
4. Check if the first character of the string is equal to the character taken from the user and if it is equal, increment the count.
5. Progress the string either wise and print the number of times the letter occurs in the string.
Here is source code of the Python Program to determine how many times a given letter occurs in a string recursively. The program output is also shown below.
if not string:
ch=raw_input(“Enter character to check:”)
Runtime Test Cases
Enter character to check:b
Enter string:hello world
Enter character to check:l