Please write a program which finds the second occurrence of a substring. If there is no second (or first) occurrence, the program should print out a message accordingly. In this exercise the occurrences cannot overlap. For example, in the string aaaa the second occurrence of the substring aa is at index 2.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter9: Records (struct)
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

Can you use Python programming language to to this question?

Thanks

Please write a program which finds the second occurrence of a substring. If there is no
second (or first) occurrence, the program should print out a message accordingly.
In this exercise the occurrences cannot overlap. For example, in the string aaaa the
second occurrence of the substring aa is at index 2.
Some examples of expected behaviour:
Please type in a string: abcabc
Please type in a substring: ab
The second occurrence of the substring is at index 3.
Please type in a string: methodology
Please type in a substring: o
The second occurrence of the substring is at index 6.
Please type in a string: aybabtu
Please type in a substring: ba
The substring does not occur twice in the string.
1
# Write your solution here
Sample output
Sample output
Sample output
Transcribed Image Text:Please write a program which finds the second occurrence of a substring. If there is no second (or first) occurrence, the program should print out a message accordingly. In this exercise the occurrences cannot overlap. For example, in the string aaaa the second occurrence of the substring aa is at index 2. Some examples of expected behaviour: Please type in a string: abcabc Please type in a substring: ab The second occurrence of the substring is at index 3. Please type in a string: methodology Please type in a substring: o The second occurrence of the substring is at index 6. Please type in a string: aybabtu Please type in a substring: ba The substring does not occur twice in the string. 1 # Write your solution here Sample output Sample output Sample output
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning