How to implement index method using loop.
sub_str is found in my_str then it will print the index of first occurrence of first character of matching string in my_str.
Input:
my_str = 'Peter Piper Picked A Peck Of Pickled Peppers.',
sub_str = 'Pickl'
Output
29
Code is below
main="Peter Piper Picked A Peck Of Pickled Peppers"
sub="Pickl"
t = main.split()
for i in range (0,len(t)):
match = True
if sub in t[i]:
print(i)
My output is 6
Expected Out is 29