Answer:
Following are the code to this question:
def after_second(s,sub):#defining a method a fter_second
first = s.find(sub)#defining a variable first that hold method find value
if first != -1:#defining if block to check first variable value not equal to -1 using slicing
s = s[len(sub)+first:]#defining s variable to calculate sub parameter length of parameter and use slicing
second = s.find(sub)#defining second variable to calculate find method value
if second != -1:#defining if block to calculate second variable slicing
return s[len(sub)+second:]#return s variable value
print(after_second("heyyoheyhi","hey"))#defining print method to call after_second method
print(after_second("11223344554321","3"))#defining print method to call after_second method
Output:
hi
44554321
Step-by-step explanation:
In the above python code a method "after_second" is declared, that accepts two-variable "s, and sub" as the parameter inside the method a first variable is declared that uses the inbuilt method "find" to find the value and stores it value. In the next step, two if blocks are used, in which both if blocks use the slicing to checks its value is not equal to "-1".
- In the first, if block the first variable is declared that uses the s variable to calculate subparameter length by using slicing and defines the second variable that finds its value and stores its value.
- In the next, if block the s variable is used to return its calculated value, and at the end of the print, the method is used to call the method by passing parameter value and prints its return value.