This program demonstrates another pattern of computation called a counter. The variable count is initialized to 0 and then incremented each time an “r” is found. When the loop exits, count contains the result: the total number of rs.
There are four errors in the following code. Fix the function so it takes a string and a character as arguments and returns the count of the character within the string.
To fix the function, ensure that the four syntax or logic errors are corrected: properly initialize the count variable to 0, use the correct loop syntax to iterate through the string, check for equality using the == operator, and properly increment the count before returning the final total.