Respuesta :
Answer:
Here is the Python code:
mystery_string = "Hello! What a fine day it is today."
mystery_character = "a"
counter = 0
for i in range(len(mystery_string)):
if (mystery_string[i] == mystery_character):
counter+=1
print (counter)
Explanation:
The above program has two variables mystery_string which contains the string Hello! What a fine day it is today and mystery_character which contains character a. The program counts and prints the number of times character a appears in the string.
It has a counter variable to store the number of times mystery_character appears in the mystery_string.
The loop has a variable i that moves through the mystery_string character by character and the loop continues to execute till i reaches the length of the mystery_string. If the character at position i is equal to the mystery_character, then counter variable counts it and increments its value to 1 each time the mystery_character is found in the mystery_string.
When the loop terminates it finally returns the number of times mystery_character appears in the mystery_string.
The screenshot of the program along with its output is attached.
