Exercise 78 **
Write a python algorithm which returns the list of all index where an occurrence occ is found within a given string s without using any predefined method as find(), rfind() , index()… The function returns the empty list , if occ does not exist in s.
s = “Python is an interpreted language. Python is open source. Python is easy to learn”
occ = “Python” , the algorithm returns the list: [0, 35, 58]
def indexOfOccurrence(s , occ):
# getting the length of the occurrence occ and the len of the string s
m = len(occ)
n = len(s)
# initializing the list of index
listIndex = 
# searching all indx of occurrence occ within the string s
for i in range(0 , n-m):
if s[i : m + i] == occ:
s = "Python is an interpreted language. Python is open source. Python is easy to learn"
occ = "Python"
# The output is: [0, 35, 58]