Question: Requirements: build a function that can find all the occurrences of a character in a string. The function should be named find _ a _
Requirements: build a function that can find all the occurrences of a character in a string.
The function should be named findachar and takes two parameters: the first one takes
in the string and the second one takes in the character to be found. Use findacharBobby
had the bat at the second base", b to test your function. The output should be formatted
like:
# @index
# @index
Hint: You may use a whileloop to continue checking to the end of the string, and use string
method find to locate the indexes of the character in the string. Or you can use a forloop
to keep checking the string character by character and check if it is the same as the second
parameter.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
