Question: Example 1 Example 2 Example 3 Example 4 abcabdab cab 2 sfuisauni sau 4 hhgywshxns wsx -1 yyyyyyy yyyy 0 Programming language: python This program,

Example 1

Example 2

Example 3

Example 4

abcabdab

cab

2

sfuisauni

sau

4

hhgywshxns

wsx

-1

yyyyyyy

yyyy

0

Programming language: python

This program, called SubstringFinder2, finds a target string in a source string and returns the index of the first character of target in source.SubstringFinder2 works as follows:

SubstringFinder2 takes a string called source as the first input.

Then, the program takes the string target as the second input.

SubstringFinder2 is supposed to check if target is a substring of source, and if yes, it returns the index of the first character of target where it appears in source.

If target does not appear in source, SubstringFinder2 prints -1.

In developing SubstringFinder2, you are not allowed to use any Python built-in methods or user-defined modules. Instead, you have to use the basic knowledge of string

processing such as the index operator, the slice operator, and string comparisons. You can see examples of SubstringFinder2 input and output in the table above. Note that your program input and output format should be exactly the same as the format of the examples shown in the table above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!