Exercise 8.4. Define the required function as indicated in the exercise. In the function, iterate over the parameter string s and use a one-way selection statement and a counting variable to determine the number of occurrences of the parameter c in the string. EX 8.4 (Occurrences of a specified character) Write a function that finds the number of occurrences of a specified character in a string using the following header: def count(s, ch): The str class has the count method. Implement your method without using the count method. For example, count("Welcome", 'e') returns 2. Write a test program that prompts the user to enter a string followed by a character and displays the number of occurrences of the character in the string.
Exercise 8.4. Define the required function as indicated in the exercise. In the function, iterate over the parameter string s and
use a one-way selection statement and a counting variable to determine the number of occurrences of the parameter c in the string.
EX 8.4 (Occurrences of a specified character) Write a function that finds the number of occurrences of a specified character in a string using the following header: def count(s, ch): The str class has the count method. Implement your method without using the count method. For example, count("Welcome", 'e') returns 2. Write a test program that prompts the user to enter a string followed by a character and displays the number of occurrences of the character in the string. |
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images