Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started