Answered step by step
Verified Expert Solution
Link Copied!

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 find_a_char() and takes two parameters: the first one takes
in the string and the second one takes in the character to be found. Use find_a_char("Bobby
had the bat at the second base", 'b') to test your function. The output should be formatted
like:
#1 @index 2
#2 @index 3
Hint: You may use a while-loop 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 for-loop
to keep checking the string character by character and check if it is the same as the second
parameter.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago